Created
April 19, 2014 15:10
Revisions
-
wuhuizuo created this gist
Apr 19, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ class Hash def deep_merge!(other_hash) other_hash.each_pair do |k, v| tv = self[k] self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v end self end def deep_merge(other_hash) dup.deep_merge!(other_hash) end end