Class: Mongoid::Fields::Serializable::Boolean
- Includes:
- Mongoid::Fields::Serializable
- Defined in:
- lib/mongoid/fields/serializable/boolean.rb
Overview
Defines the behaviour for boolean fields.
Constant Summary collapse
- MAPPINGS =
{ true => true, "true" => true, "TRUE" => true, "1" => true, 1 => true, 1.0 => true, false => false, "false" => false, "FALSE" => false, "0" => false, 0 => false, 0.0 => false }
Instance Attribute Summary
Attributes included from Mongoid::Fields::Serializable
#default_val, #label, #localize, #name, #options
Instance Method Summary collapse
-
#serialize(object) ⇒ true, false
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, #object_id_field?, #type, #versioned?
Instance Method Details
#serialize(object) ⇒ true, false
Serialize the object from the type defined in the model to a MongoDB compatible object to store.
36 37 38 39 |
# File 'lib/mongoid/fields/serializable/boolean.rb', line 36 def serialize(object) object = MAPPINGS[object] object.nil? ? nil : object end |