Class: PGTrunk::Serializers::SymbolSerializer

Inherits:
ActiveRecord::Type::Value
  • Object
show all
Defined in:
lib/pg_trunk/core/serializers/symbol_serializer.rb

Overview

Cast the attribute value as a symbol.

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/pg_trunk/core/serializers/symbol_serializer.rb', line 8

def cast(value)
  return if value.blank?
  return value if value.is_a?(Symbol)
  return value.to_sym if value.respond_to?(:to_sym)

  value.to_s.to_sym
end

#serialize(value) ⇒ Object



16
17
18
# File 'lib/pg_trunk/core/serializers/symbol_serializer.rb', line 16

def serialize(value)
  value
end