Module: OmniHooks::Utils

Defined in:
lib/omnihooks.rb

Class Method Summary collapse

Class Method Details

.deep_merge(hash, other_hash) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/omnihooks.rb', line 61

def deep_merge(hash, other_hash)
  target = hash.dup

  other_hash.keys.each do |key|
    if other_hash[key].is_a?(::Hash) && hash[key].is_a?(::Hash)
      target[key] = deep_merge(target[key], other_hash[key])
      next
    end

    target[key] = other_hash[key]
  end

  target
end