Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/magnum-pi/core_ext/deep_clone.rb

Instance Method Summary collapse

Instance Method Details

#deep_clone(cache = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/magnum-pi/core_ext/deep_clone.rb', line 53

def deep_clone(cache = {})
  return cache[self] if cache.key?(self)

  copy = super

  each do |key, value|
    copy[key] = value.deep_clone(cache)
  end

  copy
end