lib/mongoid/relations/targets/enumerable.rb in mongoid-2.2.0 vs lib/mongoid/relations/targets/enumerable.rb in mongoid-2.2.1

- old
+ new

@@ -154,11 +154,11 @@ loaded.push(doc) yield(doc) end end added.each do |doc| - next unless doc.new? + next if doc.persisted? && (!loaded? && !loaded.empty?) yield(doc) end @executed = true end @@ -314,10 +314,10 @@ # # @return [ Integer ] The size of the enumerable. # # @since 2.1.0 def size - (loaded? ? loaded.count : unloaded.count) + added.count{ |d| d.new? } + (unloaded ? unloaded.count : loaded.count) + added.count{ |d| d.new? } end alias :length :size # Send #to_json to the entries. #