Class: Enumerize::ActiveModelAttributesSupport::Type
- Inherits:
-
ActiveModel::Type::Value
- Object
- ActiveModel::Type::Value
- Enumerize::ActiveModelAttributesSupport::Type
- Defined in:
- lib/enumerize/activemodel.rb
Instance Method Summary collapse
- #deserialize(value) ⇒ Object
-
#initialize(attr) ⇒ Type
constructor
A new instance of Type.
- #serialize(value) ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(attr) ⇒ Type
Returns a new instance of Type.
33 34 35 |
# File 'lib/enumerize/activemodel.rb', line 33 def initialize(attr) @attr = attr end |
Instance Method Details
#deserialize(value) ⇒ Object
42 43 44 |
# File 'lib/enumerize/activemodel.rb', line 42 def deserialize(value) @attr.find_value(value) end |
#serialize(value) ⇒ Object
37 38 39 40 |
# File 'lib/enumerize/activemodel.rb', line 37 def serialize(value) v = @attr.find_value(value) v && v.value end |
#type ⇒ Object
29 30 31 |
# File 'lib/enumerize/activemodel.rb', line 29 def type :enumerize end |