Module: Mongoid::Extensions::Array::Deletion
- Included in:
- Array
- Defined in:
- lib/mongoid/extensions/array/deletion.rb
Overview
This module contains deletion helpers for arrays.
Instance Method Summary collapse
-
#delete_one(object) ⇒ Object
Delete the first object in the array that is equal to the supplied object and return it.
Instance Method Details
#delete_one(object) ⇒ Object
Delete the first object in the array that is equal to the supplied object and return it. This is much faster than performing a standard delete for large arrays ince it attempt to delete multiple in the other.
22 23 24 25 |
# File 'lib/mongoid/extensions/array/deletion.rb', line 22 def delete_one(object) position = index(object) position ? delete_at(position) : nil end |