lib/mongoid/relations/targets/enumerable.rb in mongoid-2.3.0 vs lib/mongoid/relations/targets/enumerable.rb in mongoid-2.3.1

- old
+ new

@@ -42,11 +42,11 @@ # # @return [ Document ] The document. # # @since 2.1.0 def <<(document) - added << document + added.push(document) end alias :push :<< # Clears out all the documents in this enumerable. If passed a block it # will yield to each document that is in memory. @@ -149,15 +149,14 @@ loaded.each do |doc| yield(doc) end else unloaded.each do |doc| - loaded.push(doc) + loaded.push(added.delete_one(doc) || doc) yield(doc) end end added.each do |doc| - next if doc.persisted? && (!loaded? && !loaded.empty?) yield(doc) end @executed = true end