module Chef::Node::Immutablize
Public Instance Methods
Source
# File lib/chef/node/immutable_collections.rb, line 35 def convert_value(value) case value when Hash if ImmutableMash === value # Save an object creation value else ImmutableMash.new(value, __root__, __node__, __precedence__) end when Array if ImmutableArray === value # Save an object creation value else ImmutableArray.new(value, __root__, __node__, __precedence__) end else # We return any already frozen strings, since that's common over the course of a run. # Check `frozen?` first since that's faster than a Class comparison value.frozen? && String === value ? value : safe_dup(value).freeze end end
Source
# File lib/chef/node/immutable_collections.rb, line 58 def immutablize(value) convert_value(value) end
Source
# File lib/chef/node/immutable_collections.rb, line 29 def safe_dup(e) e.dup rescue TypeError e end
For elements like Fixnums, true, nil…