class Mongoid::Association::Embedded::EmbedsMany::Proxy
Public Instance Methods
delete(document)
click to toggle source
Delete the supplied document from the target. This method is proxied in order to reindex the array after the operation occurs.
@example Delete the document from the relation.
person.addresses.delete(address)
@param [ Document ] document The document to be deleted.
@return [ Document, nil ] The deleted document or nil if nothing deleted.
@since 2.0.0.rc.1
# File lib/mongoid/paranoia/monkey_patches.rb, line 66 def delete(document) execute_callback :before_remove, document doc = _target.delete_one(document) if doc && !_binding? _unscoped.delete_one(doc) unless doc.paranoid? if _assigning? if doc.paranoid? doc.destroy(suppress: true) else _base.add_atomic_pull(doc) end else doc.delete(suppress: true) unbind_one(doc) end end reindex execute_callback :after_remove, document doc end
deleted()
click to toggle source
For use only with Mongoid::Paranoia
- will be removed in 4.0.
@example Get the deleted documents from the relation.
person.paranoid_phones.deleted
@return [ Criteria ] The deleted documents.
@since 3.0.10
# File lib/mongoid/paranoia/monkey_patches.rb, line 105 def deleted unscoped.deleted end