Class: Hash

Inherits:
Object show all
Defined in:
lib/zwite/ext/hash.rb

Instance Method Summary collapse

Instance Method Details

#merge_recursive(other_hash) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/zwite/ext/hash.rb', line 3

def merge_recursive(other_hash)
  target = dup
  other_hash.keys.each do |key|
    if other_hash[key].is_a?(Hash) and self[key].is_a?(Hash)
      target[key] = target[key].merge_recursive(other_hash[key])
      next
    end
    target[key] = other_hash[key]
  end
  return target
end