Module: Akami::HashHelper

Defined in:
lib/akami/hash_helper.rb

Class Method Summary collapse

Class Method Details

.deep_merge!(hash, other_hash) ⇒ Object

Returns a new Hash with hash and other_hash merged recursively. Modifies hash in place.



5
6
7
8
9
10
11
# File 'lib/akami/hash_helper.rb', line 5

def self.deep_merge!(hash, other_hash)
  other_hash.each_pair do |k,v|
    tv = hash[k]
    hash[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? deep_merge!(tv.dup, v) : v
  end
  hash
end