class PGTrunk::Serializers::ArrayOfStringsSerializer
@private Cast the attribute value as an array of strings. It knows how to cast arrays returned by PostgreSQL as a string like ‘{USD,EUR,GBP}’ into [‘USD’, ‘EUR’, ‘GBP’].
Public Instance Methods
cast(value)
click to toggle source
# File lib/pg_trunk/core/serializers/array_of_strings_serializer.rb, line 10 def cast(value) case value when ::String value.gsub(/^\{|\}$/, "").split(",") when ::NilClass then [] when ::Array then value.map(&:to_s) else [value.to_s] end end
serialize(value)
click to toggle source
# File lib/pg_trunk/core/serializers/array_of_strings_serializer.rb, line 20 def serialize(value) value end