Module: Mongoid::Extensions::Array::Accessors

Included in:
Array
Defined in:
lib/mongoid/extensions/array/accessors.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#update(attributes) ⇒ Object

If the attributes already exists in the array then they will be updated, otherwise they will be appended.



8
9
10
11
# File 'lib/mongoid/extensions/array/accessors.rb', line 8

def update(attributes)
  delete_if { |e| attributes[:_id] && (e[:_id] == attributes[:_id]) }
  self.<< attributes
end