Class: Mongoid::Relations::Embedded::Many
- Inherits:
-
Relations::Many
- Object
- Relations::Many
- Mongoid::Relations::Embedded::Many
- Defined in:
- lib/mongoid/core_ext/relations/embedded/many.rb
Instance Method Summary collapse
-
#delete(document) ⇒ Document?
Delete the supplied document from the target.
-
#deleted ⇒ Criteria
For use only with Mongoid::Paranoia - will be removed in 4.0.
Instance Method Details
#delete(document) ⇒ Document?
Delete the supplied document from the target. This method is proxied in order to reindex the array after the operation occurs.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mongoid/core_ext/relations/embedded/many.rb', line 17 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 ⇒ Criteria
For use only with Mongoid::Paranoia - will be removed in 4.0.
46 47 48 |
# File 'lib/mongoid/core_ext/relations/embedded/many.rb', line 46 def deleted unscoped.deleted end |