Module: Mongoid::Extensions::Array
- Defined in:
- lib/mongoid/extensions/array.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary (collapse)
-
- (Array<Moped::BSON::ObjectId>) __evolve_object_id__
Evolve the array into an array of object ids.
-
- (Time) __mongoize_time__
Converts the array for storing as a time.
-
- (Object) delete_one(object)
Delete the first object in the array that is equal to the supplied object and return it.
-
- (Array) mongoize
Turn the object from the ruby type we deal with to a Mongo friendly type.
-
- (true) resizable?
Is the object's size changable?.
Instance Method Details
- (Array<Moped::BSON::ObjectId>) __evolve_object_id__
Evolve the array into an array of object ids.
14 15 16 17 |
# File 'lib/mongoid/extensions/array.rb', line 14 def __evolve_object_id__ map!(&:__evolve_object_id__).compact! self end |
- (Time) __mongoize_time__
Converts the array for storing as a time.
27 28 29 |
# File 'lib/mongoid/extensions/array.rb', line 27 def __mongoize_time__ ::Time.configured.local(*self) end |
- (Object) delete_one(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.
57 58 59 60 |
# File 'lib/mongoid/extensions/array.rb', line 57 def delete_one(object) position = index(object) position ? delete_at(position) : nil end |
- (Array) mongoize
Turn the object from the ruby type we deal with to a Mongo friendly type.
40 41 42 |
# File 'lib/mongoid/extensions/array.rb', line 40 def mongoize ::Array.mongoize(self) end |
- (true) resizable?
Is the object's size changable?
70 71 72 |
# File 'lib/mongoid/extensions/array.rb', line 70 def resizable? true end |