From a924c7fa610e1e00c0343e5d81d511fbad8fa541 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Thu, 10 Dec 2015 14:36:11 -0800 Subject: Improve comments --- lib/chef/property.rb | 18 +++++++++++++++--- lib/chef/resource.rb | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/chef/property.rb b/lib/chef/property.rb index 9aaa49c313..2c7cde8651 100644 --- a/lib/chef/property.rb +++ b/lib/chef/property.rb @@ -292,9 +292,21 @@ class Chef value else - # If we are still compiling this resource (rather than running an action - # on it), reading this property before it's been set is likely the wrong - # thing. Warn if it's a duplicate of the enclosing provider. + # If the user does something like this: + # + # ``` + # class MyResource < Chef::Resource + # property :content + # action :create do + # file '/x.txt' do + # content content + # end + # end + # end + # ``` + # + # It won't do what they expect. This checks whether you try to *read* + # `content` while we are compiling the resource. if resource.respond_to?(:enclosing_provider) && resource.enclosing_provider && !resource.currently_running_action && !name_property? && diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 4864ad8816..f969ccd84c 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -624,6 +624,8 @@ class Chef # If we are currently running an action, this shows the action we are running. # If the resource is running multiple actions at once, this will show the most recent. # + # Do NOT use this. It may be removed. It is for internal purposes only. + # @api private attr_reader :currently_running_action # -- cgit v1.2.1