diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-09-26 10:04:35 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-10-25 09:29:29 -0700 |
commit | 16a08bcf2a78aa1353ec88f0a8e0282973434914 (patch) | |
tree | e23db3d83e6ed2c1f9f9baa339092fda76bb34a5 | |
parent | 69e92b100f4eccea6bf6f0953ffbc2e7f8b93b19 (diff) | |
download | chef-16a08bcf2a78aa1353ec88f0a8e0282973434914.tar.gz |
s/path_tracking/state_tracking and add __root state
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/node/attribute.rb | 6 | ||||
-rw-r--r-- | lib/chef/node/attribute_collections.rb | 8 | ||||
-rw-r--r-- | lib/chef/node/immutable_collections.rb | 6 | ||||
-rw-r--r-- | lib/chef/node/mixin/state_tracking.rb (renamed from lib/chef/node/mixin/path_tracking.rb) | 18 |
4 files changed, 25 insertions, 13 deletions
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index 438a21b964..2f498ff84c 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -18,7 +18,7 @@ # require "chef/node/mixin/immutablize_hash" -require "chef/node/mixin/path_tracking" +require "chef/node/mixin/state_tracking" require "chef/node/immutable_collections" require "chef/node/attribute_collections" require "chef/decorator/unchain" @@ -634,12 +634,12 @@ class Chef end end - # needed for PathTracking + # needed for __path def convert_key(key) key.kind_of?(Symbol) ? key.to_s : key end - prepend Chef::Node::Mixin::PathTracking + prepend Chef::Node::Mixin::StateTracking prepend Chef::Node::Mixin::ImmutablizeHash end end diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb index 2f146a9528..b8dde7121c 100644 --- a/lib/chef/node/attribute_collections.rb +++ b/lib/chef/node/attribute_collections.rb @@ -17,7 +17,7 @@ # require "chef/node/common_api" -require "chef/node/mixin/path_tracking" +require "chef/node/mixin/state_tracking" class Chef class Node @@ -105,12 +105,12 @@ class Chef end end - # needed for PathTracking + # needed for __path def convert_key(key) key end - prepend Chef::Node::Mixin::PathTracking + prepend Chef::Node::Mixin::StateTracking end # == VividMash @@ -224,7 +224,7 @@ class Chef Mash.new(self) end - prepend Chef::Node::Mixin::PathTracking + prepend Chef::Node::Mixin::StateTracking end end end diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb index 6fdd886754..d071f2ba36 100644 --- a/lib/chef/node/immutable_collections.rb +++ b/lib/chef/node/immutable_collections.rb @@ -16,7 +16,7 @@ # require "chef/node/common_api" -require "chef/node/mixin/path_tracking" +require "chef/node/mixin/state_tracking" require "chef/node/mixin/immutablize_array" require "chef/node/mixin/immutablize_hash" @@ -90,7 +90,7 @@ class Chef key end - prepend Chef::Node::Mixin::PathTracking + prepend Chef::Node::Mixin::StateTracking prepend Chef::Node::Mixin::ImmutablizeArray end @@ -174,7 +174,7 @@ class Chef h end - prepend Chef::Node::Mixin::PathTracking + prepend Chef::Node::Mixin::StateTracking prepend Chef::Node::Mixin::ImmutablizeHash end end diff --git a/lib/chef/node/mixin/path_tracking.rb b/lib/chef/node/mixin/state_tracking.rb index 58df812dd1..8f62469dc0 100644 --- a/lib/chef/node/mixin/path_tracking.rb +++ b/lib/chef/node/mixin/state_tracking.rb @@ -18,23 +18,31 @@ class Chef class Node module Mixin - module PathTracking + module StateTracking attr_reader :__path + attr_reader :__root def initialize(*args) super @__path = [] + @__root = self end def [](key) ret = super - ret.__path = __path + [ convert_key(key) ] if ret.is_a?(PathTracking) + if ret.is_a?(StateTracking) + ret.__path = __path + [ convert_key(key) ] + ret.__root = __root + end ret end def []=(key, value) ret = super - ret.__path = __path + [ convert_key(key) ] if ret.is_a?(PathTracking) + if ret.is_a?(StateTracking) + ret.__path = __path + [ convert_key(key) ] + ret.__root = __root + end ret end @@ -43,6 +51,10 @@ class Chef def __path=(path) @__path = path end + + def __root=(root) + @__root = root + end end end end |