Class: Lotus::Model::Coercer
- Inherits:
-
Object
- Object
- Lotus::Model::Coercer
- Defined in:
- lib/lotus/model/coercer.rb
Overview
Abstract coercer
It can be used as super class for custom mapping coercers.
Direct Known Subclasses
Mapping::Coercers::Array, Mapping::Coercers::BigDecimal, Mapping::Coercers::Boolean, Mapping::Coercers::Date, Mapping::Coercers::DateTime, Mapping::Coercers::Float, Mapping::Coercers::Hash, Mapping::Coercers::Integer, Mapping::Coercers::Set, Mapping::Coercers::String, Mapping::Coercers::Symbol, Mapping::Coercers::Time
Class Method Summary collapse
-
.dump(value) ⇒ Object
abstract
Serialize (dump) a Ruby object into a value that can be store by the database.
-
.load(value) ⇒ Object
abstract
Deserialize (load) a value coming from the database into a Ruby object.
Class Method Details
.dump(value) ⇒ Object
Serialize (dump) a Ruby object into a value that can be store by the database.
69 70 71 |
# File 'lib/lotus/model/coercer.rb', line 69 def self.dump(value) self.load(value) end |
.load(value) ⇒ Object
Deserialize (load) a value coming from the database into a Ruby object.
When inheriting from this class, it’s a good practice to return nil
if the given value it’s nil
.
56 57 58 |
# File 'lib/lotus/model/coercer.rb', line 56 def self.load(value) raise NotImplementedError end |