Module: Faktory::Job::Util

Defined in:
lib/faktory/job.rb

Class Method Summary collapse

Class Method Details

.deep_merge(*hashes) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/faktory/job.rb', line 230

def deep_merge(*hashes)
  initial = hashes.shift.transform_keys(&:to_s)
  hashes.reduce(initial) do |acc, other_hash|
    other_hash.transform_keys!(&:to_s)
    acc.merge(other_hash) do |_key, this_val, other_val|
      if this_val.is_a?(Hash) && other_val.is_a?(Hash)
        deep_merge(this_val, other_val)
      else
        other_val
      end
    end
  end
end