Module: Chef::Node::Immutablize
- Included in:
- Attribute, ImmutableArray, ImmutableMash
- Defined in:
- lib/chef/node/immutable_collections.rb
Instance Method Summary collapse
- #convert_value(value, path = nil) ⇒ Object
-
#safe_dup(e) ⇒ Object
For elements like Fixnums, true, nil…
Instance Method Details
#convert_value(value, path = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/chef/node/immutable_collections.rb', line 33 def convert_value(value, path = nil) case value when Hash ImmutableMash.new({}, __root__, __node__, __precedence__, path) when Array ImmutableArray.new([], __root__, __node__, __precedence__, path) else safe_dup(value).freeze end end |
#safe_dup(e) ⇒ Object
For elements like Fixnums, true, nil…
27 28 29 30 31 |
# File 'lib/chef/node/immutable_collections.rb', line 27 def safe_dup(e) e.dup rescue TypeError e end |