Class: ActiveRecord::AttributeMethods::Serialization::Attribute
- Defined in:
- activerecord/lib/active_record/attribute_methods/serialization.rb
Overview
:nodoc:
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
- #serialize ⇒ Object
- #serialized_value ⇒ Object
- #unserialize(v) ⇒ Object
- #unserialized_value(v = value) ⇒ Object
Methods inherited from Struct
Instance Attribute Details
#coder ⇒ Object
Returns the value of attribute coder
94 95 96 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 94 def coder @coder end |
#state ⇒ Object
Returns the value of attribute state
94 95 96 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 94 def state @state end |
#value ⇒ Object
Returns the value of attribute value
94 95 96 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 94 def value @value end |
Instance Method Details
#serialize ⇒ Object
108 109 110 111 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 108 def serialize self.state = :serialized self.value = coder.dump(value) end |
#serialized_value ⇒ Object
99 100 101 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 99 def serialized_value state == :unserialized ? serialize : value end |
#unserialize(v) ⇒ Object
103 104 105 106 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 103 def unserialize(v) self.state = :unserialized self.value = coder.load(v) end |
#unserialized_value(v = value) ⇒ Object
95 96 97 |
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 95 def unserialized_value(v = value) state == :serialized ? unserialize(v) : value end |