diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-10-07 16:47:43 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-10-25 09:29:29 -0700 |
commit | 9edd0113f2d046e051845cf1916fcf733d392791 (patch) | |
tree | 3d23e6552e610f3be6b860c487385e77c5b04cf4 /lib | |
parent | cbbc1c722a662596189a1a0b9aeee584b3482873 (diff) | |
download | chef-9edd0113f2d046e051845cf1916fcf733d392791.tar.gz |
rename __path to __path__ and __node to __node__lcg/node-path-tracking
consistency with Unchain here:
https://github.com/chef/chef/blob/master/lib/chef/decorator/unchain.rb#L23-L24
and with SimpleDelegator:
https://ruby-doc.org/stdlib-2.1.0/libdoc/delegate/rdoc/SimpleDelegator.html#method-i-__getobj__
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/node/attribute.rb | 2 | ||||
-rw-r--r-- | lib/chef/node/attribute_collections.rb | 16 | ||||
-rw-r--r-- | lib/chef/node/immutable_collections.rb | 4 | ||||
-rw-r--r-- | lib/chef/node/mixin/state_tracking.rb | 30 |
4 files changed, 26 insertions, 26 deletions
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index 67b114a270..2d6aff0b21 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -596,7 +596,7 @@ class Chef end end - # needed for __path + # needed for __path__ def convert_key(key) key.kind_of?(Symbol) ? key.to_s : key end diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb index 412fb52a48..b01b447978 100644 --- a/lib/chef/node/attribute_collections.rb +++ b/lib/chef/node/attribute_collections.rb @@ -94,15 +94,15 @@ class Chef when AttrArray value when Hash - VividMash.new(value, __root) + VividMash.new(value, __root__) when Array - AttrArray.new(value, __root) + AttrArray.new(value, __root__) else value end end - # needed for __path + # needed for __path__ def convert_key(key) key end @@ -143,7 +143,7 @@ class Chef # object. def delete(key, &block) - send_reset_cache(__path + [ key ]) + send_reset_cache(__path__ + [ key ]) super end @@ -161,7 +161,7 @@ class Chef def [](key) value = super if !key?(key) - value = self.class.new({}, __root) + value = self.class.new({}, __root__) self[key] = value else value @@ -170,7 +170,7 @@ class Chef def []=(key, value) ret = super - send_reset_cache(__path + [ key ]) + send_reset_cache(__path__ + [ key ]) ret end @@ -209,9 +209,9 @@ class Chef when AttrArray value when Hash - VividMash.new(value, __root) + VividMash.new(value, __root__) when Array - AttrArray.new(value, __root) + AttrArray.new(value, __root__) else value end diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb index 623290f287..938135cbee 100644 --- a/lib/chef/node/immutable_collections.rb +++ b/lib/chef/node/immutable_collections.rb @@ -27,9 +27,9 @@ class Chef def immutablize(value) case value when Hash - ImmutableMash.new(value, __root) + ImmutableMash.new(value, __root__) when Array - ImmutableArray.new(value, __root) + ImmutableArray.new(value, __root__) else value end diff --git a/lib/chef/node/mixin/state_tracking.rb b/lib/chef/node/mixin/state_tracking.rb index 2447de1c16..9be102eeeb 100644 --- a/lib/chef/node/mixin/state_tracking.rb +++ b/lib/chef/node/mixin/state_tracking.rb @@ -19,24 +19,24 @@ class Chef class Node module Mixin module StateTracking - attr_reader :__path - attr_reader :__root + attr_reader :__path__ + attr_reader :__root__ NULL = Object.new def initialize(data = NULL, root = self) - # __path and __root must be nil when we call super so it knows + # __path__ and __root__ must be nil when we call super so it knows # to avoid resetting the cache on construction data == NULL ? super() : super(data) - @__path = [] - @__root = root + @__path__ = [] + @__root__ = root end def [](key) ret = super if ret.is_a?(StateTracking) - ret.__path = __path + [ convert_key(key) ] - ret.__root = __root + ret.__path__ = __path__ + [ convert_key(key) ] + ret.__root__ = __root__ end ret end @@ -44,26 +44,26 @@ class Chef def []=(key, value) ret = super if ret.is_a?(StateTracking) - ret.__path = __path + [ convert_key(key) ] - ret.__root = __root + ret.__path__ = __path__ + [ convert_key(key) ] + ret.__root__ = __root__ end ret end protected - def __path=(path) - @__path = path + def __path__=(path) + @__path__ = path end - def __root=(root) - @__root = root + def __root__=(root) + @__root__ = root end private - def send_reset_cache(path = __path) - __root.reset_cache(path.first) if !__root.nil? && __root.respond_to?(:reset_cache) && !path.nil? + def send_reset_cache(path = __path__) + __root__.reset_cache(path.first) if !__root__.nil? && __root__.respond_to?(:reset_cache) && !path.nil? end end end |