Class: SerialTranslator::TranslationType
- Inherits:
-
ActiveRecord::Type::String
- Object
- ActiveRecord::Type::String
- SerialTranslator::TranslationType
- Defined in:
- lib/serial_translator/translation_type.rb
Instance Method Summary collapse
Instance Method Details
#cast(value) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/serial_translator/translation_type.rb', line 2 def cast(value) case value when nil {} when Hash value when /\A---/ YAML.load(value) else JSON.parse(value).symbolize_keys end end |
#serialize(value) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/serial_translator/translation_type.rb', line 15 def serialize(value) case value when String super else JSON(value) end end |