lib/mongoid/persistable.rb in mongoid-4.0.0.alpha1 vs lib/mongoid/persistable.rb in mongoid-4.0.0.alpha2
- old
+ new
@@ -140,11 +140,10 @@
#
# @return [ Object ] The result of the operation.
#
# @since 4.0.0
def prepare_atomic_operation
- # @todo: Check if the document is persisted here.
operations = yield({})
persist_or_delay_atomic_operation(operations)
self
end
@@ -203,10 +202,12 @@
#
# @param [ Hash ] operations The atomic operations.
#
# @since 4.0.0
def persist_atomic_operations(operations)
- selector = atomic_selector
- _root.collection.find(selector).update(positionally(selector, operations))
+ if persisted?
+ selector = atomic_selector
+ _root.collection.find(selector).update(positionally(selector, operations))
+ end
end
end
end