class Chef::Node::VividMash

VividMash

VividMash is identical to a Mash, with a few exceptions:

Constants

MUTATOR_METHODS

Methods that mutate a VividMash. Each of them is overridden so that it also invalidates the cached merged_attributes on the root Attribute object.

Public Class Methods

new(data = {}) click to toggle source
Calls superclass method Mash.new
# File lib/chef/node/attribute_collections.rb, line 161
def initialize(data = {})
  super(data)
end

Public Instance Methods

[](key) click to toggle source
Calls superclass method
# File lib/chef/node/attribute_collections.rb, line 165
def [](key)
  value = super
  if !key?(key)
    value = self.class.new({}, __root__)
    self[key] = value
  else
    value
  end
end
[]=(key, value) click to toggle source
Calls superclass method Mash#[]=
# File lib/chef/node/attribute_collections.rb, line 175
def []=(key, value)
  ret = super
  send_reset_cache(__path__, key)
  ret # rubocop:disable Lint/Void
end
convert_key(key) click to toggle source
Calls superclass method Mash#convert_key
# File lib/chef/node/attribute_collections.rb, line 183
def convert_key(key)
  super
end
convert_value(value) click to toggle source

Mash uses convert_value to mashify values on input. We override it here to convert hash or array values to VividMash or AttrArray for consistency and to ensure that the added parts of the attribute tree will have the correct cache invalidation behavior.

# File lib/chef/node/attribute_collections.rb, line 191
def convert_value(value)
  case value
  when VividMash
    value
  when AttrArray
    value
  when Hash
    VividMash.new(value, __root__, __node__, __precedence__)
  when Array
    AttrArray.new(value, __root__, __node__, __precedence__)
  else
    value
  end
end
delete(key, &block) click to toggle source

For all of the mutating methods on Mash, override them so that they also invalidate the cached `merged_attributes` on the root Attribute object.

Calls superclass method Mash#delete
# File lib/chef/node/attribute_collections.rb, line 149
def delete(key, &block)
  send_reset_cache(__path__, key)
  super
end
dup() click to toggle source
# File lib/chef/node/attribute_collections.rb, line 206
def dup
  Mash.new(self)
end