Parent

Class/Module Index [+]

Quicksearch

Mongoid::Fields::Serializable::ForeignKeys::Object

Defines the behaviour for integer foreign key fields.

Public Instance Methods

object_id_field?() click to toggle source

Is the field a BSON::ObjectId?

@example Is the field a BSON::ObjectId?

field.object_id_field?

@return [ true, false ] If the field is a BSON::ObjectId.

@since 2.2.0

# File lib/mongoid/fields/serializable/foreign_keys/object.rb, line 18
def object_id_field?
  @object_id_field ||=
    metadata.polymorphic? ? true : metadata.klass.using_object_ids?
end
serialize(object) click to toggle source

Serialize the object from the type defined in the model to a MongoDB compatible object to store.

@example Serialize the field.

field.serialize(object)

@param [ Object ] object The object to cast.

@return [ Array ] The converted object.

@since 2.1.0

# File lib/mongoid/fields/serializable/foreign_keys/object.rb, line 34
def serialize(object)
  object.blank? ? nil : constraint.convert(object)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.