Class: Mongoid::Fields::Serializable::ForeignKeys::Array
- Includes:
- Mongoid::Fields::Serializable
- Defined in:
- lib/mongoid/fields/serializable/foreign_keys/array.rb
Overview
Defines the behaviour for array fields.
Instance Attribute Summary
Attributes included from Mongoid::Fields::Serializable
#default_val, #label, #localize, #name, #options
Instance Method Summary collapse
-
#object_id_field? ⇒ true, false
Is the field a BSON::ObjectId?.
-
#serialize(object) ⇒ Array
Serialize the object from the type defined in the model to a MongoDB compatible object to store.
Methods included from Mongoid::Fields::Serializable
#constraint, #deserialize, #eval_default, #localized?, #metadata, #type, #versioned?
Instance Method Details
#object_id_field? ⇒ true, false
Is the field a BSON::ObjectId?
19 20 21 22 |
# File 'lib/mongoid/fields/serializable/foreign_keys/array.rb', line 19 def object_id_field? @object_id_field ||= .polymorphic? ? true : .klass.using_object_ids? end |
#serialize(object) ⇒ Array
Serialize the object from the type defined in the model to a MongoDB compatible object to store.
35 36 37 |
# File 'lib/mongoid/fields/serializable/foreign_keys/array.rb', line 35 def serialize(object) object ? constraint.convert(object) : [] end |