Class: Rakali::Utils
- Inherits:
-
Object
- Object
- Rakali::Utils
- Defined in:
- lib/rakali/utils.rb
Class Method Summary collapse
-
.deep_merge_hashes(master_hash, other_hash) ⇒ Object
This code was taken from Jekyll, available under MIT-LICENSE Copyright © 2008-2014 Tom Preston-Werner Merges a master hash with another hash, recursively.
Class Method Details
.deep_merge_hashes(master_hash, other_hash) ⇒ Object
This code was taken from Jekyll, available under MIT-LICENSE Copyright © 2008-2014 Tom Preston-Werner Merges a master hash with another hash, recursively.
master_hash - the “parent” hash whose values will be overridden other_hash - the other hash whose values will be persisted after the merge
This code was lovingly stolen from some random gem: gemjack.com/gems/tartan-0.1.1/classes/Hash.html
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rakali/utils.rb', line 14 def self.deep_merge_hashes(master_hash, other_hash) target = master_hash.dup other_hash.keys.each do |key| if other_hash[key].is_a? Hash and target[key].is_a? Hash target[key] = deep_merge_hashes(target[key], other_hash[key]) next end target[key] = other_hash[key] end target end |