Class: Chef::Node::AttrArray
- Inherits:
-
Array
- Object
- Array
- Chef::Node::AttrArray
- Includes:
- Mixin::MashyArray, Mixin::StateTracking
- Defined in:
- lib/chef/node/attribute_collections.rb
Overview
AttrArray
AttrArray is identical to Array, except that it keeps a reference to the “root” (Chef::Node::Attribute) object, and will trigger a cache invalidation on that object when mutated.
Constant Summary collapse
- MUTATOR_METHODS =
Chef::Node::Mixin::ImmutablizeArray::DISALLOWED_MUTATOR_METHODS
Instance Attribute Summary
Attributes included from Mixin::StateTracking
#__node__, #__path__, #__precedence__, #__root__
Instance Method Summary collapse
- #delete(key, &block) ⇒ Object
- #dup ⇒ Object
-
#initialize(data = []) ⇒ AttrArray
constructor
A new instance of AttrArray.
-
#safe_dup(e) ⇒ Object
For elements like Fixnums, true, nil…
- #to_yaml(*opts) ⇒ Object
Methods included from Mixin::MashyArray
#<<, #[]=, #collect!, #fill, #insert, #map!, #push, #replace, #unshift
Methods included from Mixin::StateTracking
Constructor Details
#initialize(data = []) ⇒ AttrArray
Returns a new instance of AttrArray.
52 53 54 55 |
# File 'lib/chef/node/attribute_collections.rb', line 52 def initialize(data = []) super(data) map! { |e| convert_value(e) } end |
Instance Method Details
#delete(key, &block) ⇒ Object
47 48 49 50 |
# File 'lib/chef/node/attribute_collections.rb', line 47 def delete(key, &block) send_reset_cache(__path__, key) super end |
#dup ⇒ Object
64 65 66 |
# File 'lib/chef/node/attribute_collections.rb', line 64 def dup Array.new(map { |e| safe_dup(e) }) end |
#safe_dup(e) ⇒ Object
For elements like Fixnums, true, nil…
58 59 60 61 62 |
# File 'lib/chef/node/attribute_collections.rb', line 58 def safe_dup(e) e.dup rescue TypeError e end |
#to_yaml(*opts) ⇒ Object
68 69 70 |
# File 'lib/chef/node/attribute_collections.rb', line 68 def to_yaml(*opts) to_a.to_yaml(*opts) end |