Class: ActiveRecord::AttributeMethods::Serialization::Attribute
- Defined in:
- activerecord/lib/active_record/attribute_methods/serialization.rb
Instance Attribute Summary collapse
-
#coder ⇒ Object
Returns the value of attribute coder.
-
#state ⇒ Object
Returns the value of attribute state.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
Methods inherited from Struct
Instance Attribute Details
#coder ⇒ Object
Returns the value of attribute coder
13 14 15 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 13 def coder @coder end |
#state ⇒ Object
Returns the value of attribute state
13 14 15 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 13 def state @state end |
#value ⇒ Object
Returns the value of attribute value
13 14 15 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 13 def value @value end |
Instance Method Details
#serialize ⇒ Object
27 28 29 30 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 27 def serialize self.state = :serialized self.value = coder.dump(value) end |
#serialized_value ⇒ Object
18 19 20 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 18 def serialized_value state == :unserialized ? serialize : value end |
#unserialize ⇒ Object
22 23 24 25 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 22 def unserialize self.state = :unserialized self.value = coder.load(value) end |
#unserialized_value ⇒ Object
14 15 16 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 14 def unserialized_value state == :serialized ? unserialize : value end |