Module: AR_Merge::ClassMethods
- Defined in:
- lib/ar_merge.rb
Instance Method Summary collapse
Instance Method Details
#merge_duplicates!(records, options) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ar_merge.rb', line 37 def merge_duplicates!(records,) records.each do |record| next if record.nil? records.each do |other| next if other.nil? next if other == record is_comparable = other.send([:compare]) == record.send([:compare]) next unless is_comparable #merge and remove the other records[records.index(other)]=nil record.merge!(other) end end.reject(&:nil?) end |