Class: Hash

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

Instance Method Summary collapse

Instance Method Details

#merge_recursive(o, overwrite = true) ⇒ Object



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

def merge_recursive(o, overwrite = true)
  merge(o) do |_,x,y|
    if x.respond_to?(:merge_recursive) && y.is_a?(Hash)
      x.merge_recursive(y)
    else
      if overwrite then y else [x, y].flatten.uniq end
    end
  end
end