summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-12-10 14:36:11 -0800
committerJohn Keiser <john@johnkeiser.com>2015-12-10 14:55:20 -0800
commita924c7fa610e1e00c0343e5d81d511fbad8fa541 (patch)
treea11ce0e3ac3daa5fcd41da74bcff3844d0205dcc
parent1910740592068982a4b6f9ee58452375d60281d5 (diff)
downloadchef-jk/warn-dup-property.tar.gz
Improve commentsjk/warn-dup-property
-rw-r--r--lib/chef/property.rb18
-rw-r--r--lib/chef/resource.rb2
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
#