Module: Mongoid::Extensions::Array::DeepCopy

Included in:
Array
Defined in:
lib/mongoid/extensions/array/deep_copy.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#_deep_copyArray

Make a deep copy of the array.

Examples:

Make a deep copy.

[ 1, 2, 3 ]._deep_copy

Returns:

  • (Array)

    The deep copy.

Since:

  • 2.4.0



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

def _deep_copy
  [].tap do |copy|
    each do |value|
      copy.push(value._deep_copy)
    end
  end
end