summaryrefslogtreecommitdiff
path: root/chef/lib
diff options
context:
space:
mode:
authorToomas Pelberg <toomas.pelberg@playtech.com>2010-08-09 15:09:02 +0300
committerDaniel DeLeo <dan@opscode.com>2010-08-22 11:37:58 -0700
commitabe2a9ffe2b151f963cd377e675cfb5f509b4a22 (patch)
tree8a39594f8c45c4ae72ad7056e09c946c8ecb3b60 /chef/lib
parent907884b6630b4547775c0ea638ccae00eb0cd2fc (diff)
downloadchef-abe2a9ffe2b151f963cd377e675cfb5f509b4a22.tar.gz
Check for existance of keys not only their values ( CHEF-871 )
Diffstat (limited to 'chef/lib')
-rw-r--r--chef/lib/chef/node/attribute.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/chef/lib/chef/node/attribute.rb b/chef/lib/chef/node/attribute.rb
index a4799f8389..0b70e498a8 100644
--- a/chef/lib/chef/node/attribute.rb
+++ b/chef/lib/chef/node/attribute.rb
@@ -123,6 +123,10 @@ class Chef
end
def has_key?(key)
+ return true if exists_in_hash(@default.to_hash,key)
+ return true if exists_in_hash(@automatic.to_hash,key)
+ return true if exists_in_hash(@normal.to_hash,key)
+ return true if exists_in_hash(@override.to_hash,key)
attribute?(key)
end
@@ -448,6 +452,11 @@ class Chef
end
end
+ def exists_in_hash(data_hash,key)
+ return true if (@state.length == 0 && data_hash.has_key?(key))
+ return true if (data_hash.has_key?(@state.to_s) && data_hash[@state.to_s].respond_to?(:has_key?) && data_hash[@state.to_s].has_key?(key) )
+ end
+
end
end
end