Module: XlsFunction::Extensions::HashExtension

Defined in:
lib/xls_function/extensions/hash_extension.rb

Class Method Summary collapse

Class Method Details

.deep_merge(source, other, &block) ⇒ Object

Parameters:

  • source (Hash)
  • other (Hash)


7
8
9
10
11
12
13
14
# File 'lib/xls_function/extensions/hash_extension.rb', line 7

def deep_merge(source, other, &block)
  source.merge(other) do |key, oldval, newval|
    next deep_merge(oldval, newval, &block) if oldval.is_a?(Hash) && newval.is_a?(Hash)
    next block.call(key, oldval, newval) if block_given?

    newval
  end
end