Class: Hash

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

Instance Method Summary collapse

Instance Method Details

#recursive_merge(hash) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/hash.rb', line 2

def recursive_merge(hash)
  target = dup
  hash.keys.each do |key|
    target[key] = if hash[key].is_a?(Hash) && self[key].is_a?(Hash)
      target[key].recursive_merge(hash[key])
    else hash[key]
    end
  end
  target
end