Class: Chef::Node::AttrArray
- Inherits:
-
Array
- Object
- Array
- Chef::Node::AttrArray
- Includes:
- 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 =
[ :<<, :[]=, :clear, :collect!, :compact!, :default=, :default_proc=, :delete_at, :delete_if, :fill, :flatten!, :insert, :keep_if, :map!, :merge!, :pop, :push, :update, :reject!, :reverse!, :replace, :select!, :shift, :slice!, :sort!, :sort_by!, :uniq!, :unshift, ]
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…
Methods included from Mixin::StateTracking
Constructor Details
#initialize(data = []) ⇒ AttrArray
Returns a new instance of AttrArray.
76 77 78 79 |
# File 'lib/chef/node/attribute_collections.rb', line 76 def initialize(data = []) super(data) map! { |e| convert_value(e) } end |
Instance Method Details
#delete(key, &block) ⇒ Object
71 72 73 74 |
# File 'lib/chef/node/attribute_collections.rb', line 71 def delete(key, &block) send_reset_cache(__path__, key) super end |
#dup ⇒ Object
88 89 90 |
# File 'lib/chef/node/attribute_collections.rb', line 88 def dup Array.new(map { |e| safe_dup(e) }) end |
#safe_dup(e) ⇒ Object
For elements like Fixnums, true, nil…
82 83 84 85 86 |
# File 'lib/chef/node/attribute_collections.rb', line 82 def safe_dup(e) e.dup rescue TypeError e end |