module Chef::Node::Mixin::StateTracking
Attributes
__node__[R]
__path__[R]
__precedence__[R]
__root__[R]
Public Class Methods
new(data = nil, root = self, node = nil, precedence = nil)
click to toggle source
Calls superclass method
# File lib/chef/node/mixin/state_tracking.rb, line 27 def initialize(data = nil, root = self, node = nil, precedence = nil) # __path__ and __root__ must be nil when we call super so it knows # to avoid resetting the cache on construction data.nil? ? super() : super(data) @__path__ = [] @__root__ = root @__node__ = node @__precedence__ = precedence end
Public Instance Methods
[](*args)
click to toggle source
Calls superclass method
# File lib/chef/node/mixin/state_tracking.rb, line 37 def [](*args) ret = super key = args.first next_path = [ __path__, convert_key(key) ].flatten next_path.compact! copy_state_to(ret, next_path) end
[]=(*args)
click to toggle source
Calls superclass method
# File lib/chef/node/mixin/state_tracking.rb, line 45 def []=(*args) ret = super key = args.first value = args.last next_path = [ __path__, convert_key(key) ].flatten next_path.compact! send_attribute_changed_event(next_path, value) copy_state_to(ret, next_path) end
Protected Instance Methods
__node__=(node)
click to toggle source
# File lib/chef/node/mixin/state_tracking.rb, line 69 def __node__=(node) @__node__ = node end
__path__=(path)
click to toggle source
# File lib/chef/node/mixin/state_tracking.rb, line 57 def __path__=(path) @__path__ = path end
__precedence__=(precedence)
click to toggle source
# File lib/chef/node/mixin/state_tracking.rb, line 65 def __precedence__=(precedence) @__precedence__ = precedence end
__root__=(root)
click to toggle source
# File lib/chef/node/mixin/state_tracking.rb, line 61 def __root__=(root) @__root__ = root end
Private Instance Methods
copy_state_to(ret, next_path)
click to toggle source
# File lib/chef/node/mixin/state_tracking.rb, line 87 def copy_state_to(ret, next_path) if ret.is_a?(StateTracking) ret.__path__ = next_path ret.__root__ = __root__ ret.__node__ = __node__ ret.__precedence__ = __precedence__ end ret end
send_attribute_changed_event(next_path, value)
click to toggle source
# File lib/chef/node/mixin/state_tracking.rb, line 75 def send_attribute_changed_event(next_path, value) if __node__ && __node__.run_context && __node__.run_context.events __node__.run_context.events.attribute_changed(__precedence__, next_path, value) end end
send_reset_cache(path = nil, key = nil)
click to toggle source
# File lib/chef/node/mixin/state_tracking.rb, line 81 def send_reset_cache(path = nil, key = nil) next_path = [ path, key ].flatten next_path.compact! __root__.reset_cache(next_path.first) if !__root__.nil? && __root__.respond_to?(:reset_cache) end