Skip to content

Commit

Permalink
We can assign and check at the same time.
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Apr 1, 2011
1 parent 782ddfe commit d41ad5b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/mongoid/relations/builders/nested_attributes/many.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,10 @@ def over_limit?(attributes)
# attrs: The single document attributes to process.
def process(attrs)
return if reject?(attrs)
if attrs[:id] or attrs['id'] or attrs['_id']
id = attrs[:id] || attrs['id'] || attrs['_id']
if id = attrs[:id] || attrs["id"] || attrs["_id"]
document = existing.find(convert_id(id))
destroyable?(attrs) ? document.destroy : document.update_attributes(attrs)
else
# @todo: Durran: Tell the push not to save the base and call it
# after all processing is done. This is related to #581.
existing.push(metadata.klass.new(attrs)) unless destroyable?(attrs)
end
end
Expand Down

0 comments on commit d41ad5b

Please sign in to comment.