recursively merge Hash.
1 2 class Hash 3 def recursive_merge(h) 4 self.merge!(h) {|key, _old, _new| if _old.class == Hash then _old.recursive_merge(_new) else _new end } 5 end 6 end
DZone Snippets > mancjew > ruby
12969 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Rex Chung www.rorcraft.com
1 2 class Hash 3 def recursive_merge(h) 4 self.merge!(h) {|key, _old, _new| if _old.class == Hash then _old.recursive_merge(_new) else _new end } 5 end 6 end