Module: Chef::Node::Mixin::StateTracking

Included in:
AttrArray, Attribute, ImmutableArray, ImmutableMash, VividMash
Defined in:
lib/chef/node/mixin/state_tracking.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#__node__Object

Returns the value of attribute __node__.



24
25
26
# File 'lib/chef/node/mixin/state_tracking.rb', line 24

def __node__
  @__node__
end

#__path__Object

Returns the value of attribute __path__.



22
23
24
# File 'lib/chef/node/mixin/state_tracking.rb', line 22

def __path__
  @__path__
end

#__precedence__Object

Returns the value of attribute __precedence__.



25
26
27
# File 'lib/chef/node/mixin/state_tracking.rb', line 25

def __precedence__
  @__precedence__
end

#__root__Object

Returns the value of attribute __root__.



23
24
25
# File 'lib/chef/node/mixin/state_tracking.rb', line 23

def __root__
  @__root__
end

Instance Method Details

#[](*args) ⇒ Object



37
38
39
40
41
42
# File 'lib/chef/node/mixin/state_tracking.rb', line 37

def [](*args)
  ret = super
  key = args.first
  next_path = [ __path__, convert_key(key) ].flatten.compact
  copy_state_to(ret, next_path)
end

#[]=(*args) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/chef/node/mixin/state_tracking.rb', line 44

def []=(*args)
  ret = super
  key = args.first
  value = args.last
  next_path = [ __path__, convert_key(key) ].flatten.compact
  send_attribute_changed_event(next_path, value)
  copy_state_to(ret, next_path)
end

#initialize(data = nil, root = self, node = nil, precedence = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
# 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