Module: DeepClone::Extensions::Hash

Defined in:
lib/deep_clone/extensions/hash.rb

Instance Method Summary collapse

Instance Method Details

#__deep_clone__Hash

Make a deep copy of this hash.

Examples:

Make a deep copy of the hash.

{ field: value }.__deep_clone__

Returns:

  • (Hash)

    The copied hash.



12
13
14
15
16
17
18
# File 'lib/deep_clone/extensions/hash.rb', line 12

def __deep_clone__
  {}.tap do |copy|
    each_pair do |key, value|
      copy.store(key, value.__deep_clone__)
    end
  end
end