summaryrefslogtreecommitdiff
path: root/lib/chef/property.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-10-31 15:45:21 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-10-31 15:45:21 -0700
commitb6f81d6f6702f5f13e3e0307c8253d1ef949645b (patch)
treeac7d95b3c5d5321932ab8485d5d765500b139501 /lib/chef/property.rb
parentfc30a44a383f5742236110002580d0c40380718c (diff)
downloadchef-b6f81d6f6702f5f13e3e0307c8253d1ef949645b.tar.gz
improve property-resource namespace collision exception
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/property.rb')
-rw-r--r--lib/chef/property.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index a357ba9ee3..9433326b5b 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -522,22 +522,22 @@ class Chef
# stack trace if you use `define_method`.
declared_in.class_eval <<-EOM, __FILE__, __LINE__ + 1
def #{name}(value=NOT_PASSED)
- raise "Property #{name} of \#{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block_given?
+ raise "Property `#{name}` of `\#{self}` was incorrectly passed a block. Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block_given?
self.class.properties[#{name.inspect}].call(self, value)
end
def #{name}=(value)
- raise "Property #{name} of \#{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block_given?
+ raise "Property `#{name}` of `\#{self}` was incorrectly passed a block. Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block_given?
self.class.properties[#{name.inspect}].set(self, value)
end
EOM
rescue SyntaxError
# If the name is not a valid ruby name, we use define_method.
declared_in.define_method(name) do |value = NOT_PASSED, &block|
- raise "Property #{name} of #{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block
+ raise "Property `#{name}` of `#{self}` was incorrectly passed a block! Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block
self.class.properties[name].call(self, value)
end
declared_in.define_method("#{name}=") do |value, &block|
- raise "Property #{name} of #{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block
+ raise "Property `#{name}` of `#{self}` was incorrectly passed a block! Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block
self.class.properties[name].set(self, value)
end
end