Method: Mongoid::Fields::Serializable::ObjectId#serialize
- Defined in:
- lib/mongoid/fields/serializable/object_id.rb
#serialize(object) ⇒ BSON::ObjectId
Serialize the object from the type defined in the model to a MongoDB compatible object to store.
21 22 23 24 25 26 27 |
# File 'lib/mongoid/fields/serializable/object_id.rb', line 21 def serialize(object) if object.is_a?(::String) BSON::ObjectId.from_string(object) unless object.blank? else object end end |