class Rakali::Utils
Public Class Methods
deep_merge_hashes(master_hash, other_hash)
click to toggle source
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
# 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