Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/rsmp/deep_merge.rb

Instance Method Summary collapse

Instance Method Details

#deep_merge(other_hash) ⇒ Object


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

def deep_merge(other_hash)
  self.merge(other_hash) do |key, old, fresh|
    if old.is_a?(Hash) && fresh.is_a?(Hash)
      old.deep_merge(fresh)
    else
      fresh
    end
  end
end