Class: Evey::Types::Association
- Inherits:
-
ActiveRecord::Type::Value
- Object
- ActiveRecord::Type::Value
- Evey::Types::Association
- Defined in:
- lib/evey/types/association.rb
Instance Method Summary collapse
Instance Method Details
#cast(hash) ⇒ Object
6 7 8 9 10 |
# File 'lib/evey/types/association.rb', line 6 def cast(hash) return if hash.nil? hash.transform_values { |v| GlobalID::Locator.locate(v) } end |
#deserialize(hash) ⇒ Object
12 13 14 15 16 |
# File 'lib/evey/types/association.rb', line 12 def deserialize(hash) return cast(hash) unless hash.is_a?(::String) cast(decode_value(hash)) end |
#serialize(hash) ⇒ Object
18 19 20 21 22 |
# File 'lib/evey/types/association.rb', line 18 def serialize(hash) return if hash.nil? ::ActiveSupport::JSON.encode(hash.transform_values { |v| v.to_global_id.to_s }) end |
#type ⇒ Object
2 3 4 |
# File 'lib/evey/types/association.rb', line 2 def type :json end |