Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_form_with_client_validation/core_ext/hash.rb

Instance Method Summary collapse

Instance Method Details

#deep_dupObject

Returns a deep copy of hash.



7
8
9
10
11
12
13
14
# File 'lib/simple_form_with_client_validation/core_ext/hash.rb', line 7

def deep_dup
  duplicate = self.dup
  duplicate.each_pair do |k,v|
    tv = duplicate[k]
    duplicate[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_dup : v
  end
  duplicate
end