Class: Mongoid::Fields::Serializable::Integer
- Includes:
- Mongoid::Fields::Serializable
- Defined in:
- lib/mongoid/fields/serializable/integer.rb
Overview
Defines the behaviour for integer fields.
Instance Attribute Summary
Attributes included from Mongoid::Fields::Serializable
#default_val, #label, #localize, #name, #options
Instance Method Summary collapse
-
#serialize(object) ⇒ Integer
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) ⇒ Integer
Serialize the object from the type defined in the model to a MongoDB compatible object to store.
21 22 23 24 |
# File 'lib/mongoid/fields/serializable/integer.rb', line 21 def serialize(object) return nil if object.blank? numeric(object) rescue object end |