module Mongoid::Extensions::Array::ClassMethods
Public Instance Methods
__mongoize_fk__(association, object)
click to toggle source
Convert the provided object to a proper array of foreign keys.
@example Mongoize the object.
Array.__mongoize_fk__(constraint, object)
@param [ Mongoid::Association::Relatable
] association The association metadata. @param [ Object
] object The object to convert.
@return [ Array
] The array of ids. @deprecated
# File lib/mongoid/extensions/array.rb, line 118 def __mongoize_fk__(association, object) if object.resizable? object.blank? ? object : association.convert_to_foreign_key(object) else object.blank? ? [] : association.convert_to_foreign_key(Array(object)) end end
mongoize(object)
click to toggle source
Turn the object from the ruby type we deal with to a Mongo friendly type.
@example Mongoize the object.
Array.mongoize([ 1, 2, 3 ])
@param [ Object
] object The object to mongoize.
@return [ Array
| nil ] The object mongoized or nil.
# File lib/mongoid/extensions/array.rb, line 136 def mongoize(object) return if object.nil? case object when ::Array, ::Set object.map(&:mongoize) end end
resizable?()
click to toggle source
Returns whether the object’s size can be changed.
@example Is the object resizable?
Array.resizable?
@return [ true ] true.
# File lib/mongoid/extensions/array.rb, line 150 def resizable? true end