Class: Hash
Instance Method Summary collapse
Instance Method Details
#deep_merge(other) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/cfoo/processor.rb', line 3 def deep_merge(other) merge(other) do |key, our_item, their_item| if [our_item, their_item].all? {|item| item.respond_to? :deep_merge } our_item.deep_merge(their_item) elsif [our_item, their_item].all? {|item| item.respond_to?(:+) && item.respond_to?(:uniq) } our_item.concat(their_item).uniq else their_item end end end |