Class: HashType
- Inherits:
-
ActiveModel::Type::Value
- Object
- ActiveModel::Type::Value
- HashType
- Defined in:
- app/types/hash_type.rb
Instance Method Summary collapse
Instance Method Details
#cast(value) ⇒ Object
2 3 4 |
# File 'app/types/hash_type.rb', line 2 def cast(value) value.is_a?(String) ? JSON.parse(value) : value.to_h end |
#deserialize(value) ⇒ Object
10 11 12 |
# File 'app/types/hash_type.rb', line 10 def deserialize(value) cast(value) end |
#serialize(value) ⇒ Object
6 7 8 |
# File 'app/types/hash_type.rb', line 6 def serialize(value) value.to_json end |