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 [ Association
] association The association metadata. @param [ Object
] object The object to convert.
@return [ Array
] The array of ids.
@since 3.0.0
# File lib/mongoid/extensions/array.rb, line 153 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
] The object mongoized.
@since 3.0.0
# File lib/mongoid/extensions/array.rb, line 172 def mongoize(object) if object.is_a?(::Array) evolve(object).collect{ |obj| obj.class.mongoize(obj) } else evolve(object) end end
resizable?()
click to toggle source
Is the object’s size changable?
@example Is the object resizable?
Array.resizable?
@return [ true ] true.
@since 3.0.0
# File lib/mongoid/extensions/array.rb, line 188 def resizable? true end