Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def deep_merge!(other_hash, &block)
other_hash.each_pair do |k,v|
tv = self[k]
self[k] = (tv.is_a?(Hash) && v.is_a?(Hash)) ? tv.deep_merge(v, &block) : (block_given? and (!tv.nil? and !v.nil?)) ? yield(k, tv, v) : v
end
self
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment