Module: Mongoid::Extensions::Hash::DeepCopy

Included in:
Hash
Defined in:
lib/mongoid/extensions/hash/deep_copy.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#_deep_copyHash

Make a deep copy of the hash.

Examples:

Make a deep copy.

{ :test => "value" }._deep_copy

Returns:

  • (Hash)

    The deep copy.

Since:

  • 2.4.0



15
16
17
18
19
20
21
# File 'lib/mongoid/extensions/hash/deep_copy.rb', line 15

def _deep_copy
  {}.tap do |copy|
    each_pair do |key, value|
      copy[key] = value._deep_copy
    end
  end
end