Class: ActiveRecord::AttributeMethods::Serialization::Type
- Inherits:
-
Object
- Object
- ActiveRecord::AttributeMethods::Serialization::Type
- Defined in:
- lib/active_record/attribute_methods/serialization.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(column) ⇒ Type
constructor
A new instance of Type.
- #type ⇒ Object
- #type_cast(value) ⇒ Object
Constructor Details
#initialize(column) ⇒ Type
Returns a new instance of Type.
72 73 74 |
# File 'lib/active_record/attribute_methods/serialization.rb', line 72 def initialize(column) @column = column end |
Instance Method Details
#type ⇒ Object
84 85 86 |
# File 'lib/active_record/attribute_methods/serialization.rb', line 84 def type @column.type end |
#type_cast(value) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/active_record/attribute_methods/serialization.rb', line 76 def type_cast(value) if value.state == :serialized value.unserialized_value @column.type_cast value.value else value.unserialized_value end end |