Class: PGTrunk::Serializers::ArrayOfSymbolsSerializer
- Inherits:
-
ActiveRecord::Type::Value
- Object
- ActiveRecord::Type::Value
- PGTrunk::Serializers::ArrayOfSymbolsSerializer
- Defined in:
- lib/pg_trunk/core/serializers/array_of_symbols_serializer.rb
Overview
The same as the array of strings with symbolization at the end
Instance Method Summary collapse
Instance Method Details
#cast(value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pg_trunk/core/serializers/array_of_symbols_serializer.rb', line 8 def cast(value) case value when ::NilClass then [] when ::Symbol then [value] when ::String value.gsub(/^\{|\}$/, "").split(",").map(&:to_sym) when ::Array then value.map { |i| i.to_s.to_sym } else [value.to_s.to_sym] end end |
#serialize(value) ⇒ Object
19 20 21 |
# File 'lib/pg_trunk/core/serializers/array_of_symbols_serializer.rb', line 19 def serialize(value) value end |