Class: PaperTrail::TypeSerializers::PostgresArraySerializer
- Inherits:
-
Object
- Object
- PaperTrail::TypeSerializers::PostgresArraySerializer
- Defined in:
- lib/mongo_trails/type_serializers/postgres_array_serializer.rb
Overview
Provides an alternative method of serialization and deserialization of PostgreSQL array columns.
Instance Method Summary collapse
- #deserialize(array) ⇒ Object
-
#initialize(subtype, delimiter) ⇒ PostgresArraySerializer
constructor
A new instance of PostgresArraySerializer.
- #serialize(array) ⇒ Object
Constructor Details
#initialize(subtype, delimiter) ⇒ PostgresArraySerializer
Returns a new instance of PostgresArraySerializer.
8 9 10 11 |
# File 'lib/mongo_trails/type_serializers/postgres_array_serializer.rb', line 8 def initialize(subtype, delimiter) @subtype = subtype @delimiter = delimiter end |
Instance Method Details
#deserialize(array) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mongo_trails/type_serializers/postgres_array_serializer.rb', line 18 def deserialize(array) return deserialize_with_ar(array) if active_record_pre_502? case array # Needed for legacy reasons. If serialized array is a string # then it was serialized with Rails < 5.0.2. when ::String then deserialize_with_ar(array) else array end end |
#serialize(array) ⇒ Object
13 14 15 16 |
# File 'lib/mongo_trails/type_serializers/postgres_array_serializer.rb', line 13 def serialize(array) return serialize_with_ar(array) if active_record_pre_502? array end |