Module: DeepMerge::DeepMergeArray

Defined in:
lib/deepmerge.rb

Overview

inject this method into the Array class to add deep merging functionality to Arrays

Instance Method Summary collapse

Instance Method Details

#deep_merge(other) ⇒ Object



10
11
12
# File 'lib/deepmerge.rb', line 10

def deep_merge(other)
  (self+other).uniq
end

#deep_merge!(other) ⇒ Object



14
15
16
17
18
# File 'lib/deepmerge.rb', line 14

def deep_merge!(other)
  # in ruby, uniq! returns nil if there are no changes unlike uniq which returns the array
  # because of this uniq has to be used here with a replacement instead of uniq!
  replace(concat(other).uniq)
end