Class: Eventsimple::MetadataType
- Inherits:
-
ActiveModel::Type::Value
- Object
- ActiveModel::Type::Value
- Eventsimple::MetadataType
- Defined in:
- lib/eventsimple/metadata_type.rb
Instance Method Summary collapse
Instance Method Details
#cast_value(value) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/eventsimple/metadata_type.rb', line 9 def cast_value(value) case value when String decoded = ActiveSupport::JSON.decode(value) return decoded if decoded.empty? Eventsimple.configuration..new(decoded) when Hash Eventsimple.configuration..new(value) when Eventsimple.configuration. value end end |
#deserialize(value) ⇒ Object
32 33 34 35 36 |
# File 'lib/eventsimple/metadata_type.rb', line 32 def deserialize(value) decoded = ActiveSupport::JSON.decode(value) Eventsimple.configuration..new(decoded) end |
#serialize(value) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/eventsimple/metadata_type.rb', line 23 def serialize(value) case value when Hash, Eventsimple.configuration. ActiveSupport::JSON.encode(value) else super end end |
#type ⇒ Object
5 6 7 |
# File 'lib/eventsimple/metadata_type.rb', line 5 def type :metadata_type end |