Class: Mongoid::Relations::Embedded::Many
- Inherits:
-
Relations::Many
- Object
- Relations::Many
- Mongoid::Relations::Embedded::Many
- Defined in:
- lib/mongoid/paranoia/monkey_patches.rb,
lib/mongoid/paranoia/monkey_patches.rb
Overview
This class handles the behaviour for a document that embeds many other documents within in it as an array.
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.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/mongoid/paranoia/monkey_patches.rb', line 68 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.
105 106 107 |
# File 'lib/mongoid/paranoia/monkey_patches.rb', line 105 def deleted unscoped.deleted end |