diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-10-28 14:46:11 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-10-28 14:46:11 -0700 |
commit | e57e29b96b75ff7fc04abb7f9db73920b2a5894a (patch) | |
tree | bd54ab59d6c7606efdaf8fa8d07a8b79f594c0a4 /lib/chef/node/attribute.rb | |
parent | 95dd383a6059d896e5c587b6a6eb65195e144a28 (diff) | |
download | chef-e57e29b96b75ff7fc04abb7f9db73920b2a5894a.tar.gz |
add attribute_changed hook to event handlers
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/node/attribute.rb')
-rw-r--r-- | lib/chef/node/attribute.rb | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index 2d6aff0b21..d5b0ee5d72 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -187,21 +187,22 @@ class Chef # return the automatic level attribute component attr_reader :automatic - def initialize(normal, default, override, automatic) - @default = VividMash.new(default, self) - @env_default = VividMash.new({}, self) - @role_default = VividMash.new({}, self) - @force_default = VividMash.new({}, self) + def initialize(normal, default, override, automatic, node = nil) + @default = VividMash.new(default, self, node, :default) + @env_default = VividMash.new({}, self, node, :env_default) + @role_default = VividMash.new({}, self, node, :role_default) + @force_default = VividMash.new({}, self, node, :force_default) - @normal = VividMash.new(normal, self) + @normal = VividMash.new(normal, self, node, :normal) - @override = VividMash.new(override, self) - @role_override = VividMash.new({}, self) - @env_override = VividMash.new({}, self) - @force_override = VividMash.new({}, self) + @override = VividMash.new(override, self, node, :override) + @role_override = VividMash.new({}, self, node, :role_override) + @env_override = VividMash.new({}, self, node, :env_override) + @force_override = VividMash.new({}, self, node, :force_override) - @automatic = VividMash.new(automatic, self) - super() + @automatic = VividMash.new(automatic, self, node, :automatic) + + super(nil, self, node, :merged) end # Debug what's going on with an attribute. +args+ is a path spec to the @@ -232,59 +233,59 @@ class Chef # Set the cookbook level default attribute component to +new_data+. def default=(new_data) reset - @default = VividMash.new(new_data, self) + @default = VividMash.new(new_data, self, __node__, :default) end # Set the role level default attribute component to +new_data+ def role_default=(new_data) reset - @role_default = VividMash.new(new_data, self) + @role_default = VividMash.new(new_data, self, __node__, :role_default) end # Set the environment level default attribute component to +new_data+ def env_default=(new_data) reset - @env_default = VividMash.new(new_data, self) + @env_default = VividMash.new(new_data, self, __node__, :env_default) end # Set the force_default (+default!+) level attributes to +new_data+ def force_default=(new_data) reset - @force_default = VividMash.new(new_data, self) + @force_default = VividMash.new(new_data, self, __node__, :force_default) end # Set the normal level attribute component to +new_data+ def normal=(new_data) reset - @normal = VividMash.new(new_data, self) + @normal = VividMash.new(new_data, self, __node__, :normal) end # Set the cookbook level override attribute component to +new_data+ def override=(new_data) reset - @override = VividMash.new(new_data, self) + @override = VividMash.new(new_data, self, __node__, :override) end # Set the role level override attribute component to +new_data+ def role_override=(new_data) reset - @role_override = VividMash.new(new_data, self) + @role_override = VividMash.new(new_data, self, __node__, :role_override) end # Set the environment level override attribute component to +new_data+ def env_override=(new_data) reset - @env_override = VividMash.new(new_data, self) + @env_override = VividMash.new(new_data, self, __node__, :env_override) end def force_override=(new_data) reset - @force_override = VividMash.new(new_data, self) + @force_override = VividMash.new(new_data, self, __node__, :force_override) end def automatic=(new_data) reset - @automatic = VividMash.new(new_data, self) + @automatic = VividMash.new(new_data, self, __node__, :automatic) end # @@ -480,6 +481,7 @@ class Chef if symbol == :to_ary merged_attributes.send(symbol, *args) elsif args.empty? + puts symbol Chef.log_deprecation %q{method access to node attributes (node.foo.bar) is deprecated and will be removed in Chef 13, please use bracket syntax (node["foo"]["bar"])} if key?(symbol) self[symbol] @@ -565,7 +567,7 @@ class Chef return nil if components.compact.empty? - components.inject(ImmutableMash.new({}, self)) do |merged, component| + components.inject(ImmutableMash.new({}, self, __node__, :merged)) do |merged, component| Chef::Mixin::DeepMerge.hash_only_merge!(merged, component) end end |