module OmniHooks::Utils

Public Instance Methods

deep_merge(hash, other_hash) click to toggle source
# 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