Method: Mongoid::Extensions::Object::ClassMethods#__mongoize_fk__

Defined in:
lib/mongoid/extensions/object.rb

#__mongoize_fk__(constraint, object) ⇒ Object

Convert the provided object to a foreign key, given the metadata key contstraint.

Examples:

Convert the object to a fk.

Object.__mongoize_fk__(constraint, object)

Parameters:

  • constraint (Constraint)

    The constraint.

  • object (Object)

    The object to convert.

Returns:

  • (Object)

    The converted object.

Since:

  • 3.0.0



235
236
237
238
# File 'lib/mongoid/extensions/object.rb', line 235

def __mongoize_fk__(constraint, object)
  return nil if !object || object == ""
  constraint.convert(object)
end