Module: DeepCover::Tools::Merge

Defined in:
lib/deep_cover/tools/merge.rb

Instance Method Summary collapse

Instance Method Details

#merge(*hashes) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/deep_cover/tools/merge.rb', line 5

def merge(*hashes)
  if hashes.last.is_a?(Symbol)
    oper = hashes.pop
    merge(*hashes) { |a, b| a.public_send(oper, b) }
  elsif !block_given?
    merge(*hashes, &:last)
  else
    hashes.inject { |result, h| result.merge(h) { |key, a, b| yield [a, b] } }
  end
end