Convert the provided object to a foreign key, given the metadata key contstraint.
@example Convert the object to a fk.
Object.__mongoize_fk__(constraint, object)
@param [ Constraint ] constraint The constraint. @param [ Object ] object The object to convert.
@return [ Object ] The converted object.
@since 3.0.0
# File lib/mongoid/extensions/object.rb, line 234 def __mongoize_fk__(constraint, object) return nil if !object || object == "" constraint.convert(object) end
Convert the object from its mongo friendly ruby type to this type.
@example Demongoize the object.
Object.demongoize(object)
@param [ Object ] object The object to demongoize.
@return [ Object ] The object.
@since 3.0.0
# File lib/mongoid/extensions/object.rb, line 249 def demongoize(object) object end
Turn the object from the ruby type we deal with to a Mongo friendly type.
@example Mongoize the object.
Object.mongoize("123.11")
@param [ Object ] object The object to mongoize.
@return [ Object ] The object mongoized.
@since 3.0.0
# File lib/mongoid/extensions/object.rb, line 264 def mongoize(object) object.mongoize end