Skip to content

Instantly share code, notes, and snippets.

@emrekutlu
Created June 21, 2010 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emrekutlu/447516 to your computer and use it in GitHub Desktop.
Save emrekutlu/447516 to your computer and use it in GitHub Desktop.
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