module ThousandIsland::Utilities::DeepMerge

Public Instance Methods

merge_for_key_and_nested_keys(key, keys, *hashes) click to toggle source
# File lib/thousand_island/utilities/utilities.rb, line 6
def merge_for_key_and_nested_keys(key, keys, *hashes)
  temp = {}
  merged = {}
  hashes.each do |h|
    keys.each do |k|
      temp[k] = {} unless temp.has_key? k
      temp[k].merge!(h[key][k]) if h[key] && h[key][k]
    end
    merged.merge!(h[key]) if h[key]
  end
  merged.merge(temp)
end