Class: PaperTrail::TypeSerializers::PostgresArraySerializer
- Inherits:
-
Object
- Object
- PaperTrail::TypeSerializers::PostgresArraySerializer
- Defined in:
- lib/paper_trail/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/paper_trail/type_serializers/postgres_array_serializer.rb', line 8 def initialize(subtype, delimiter) @subtype = subtype @delimiter = delimiter end |
Instance Method Details
#deserialize(array) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/paper_trail/type_serializers/postgres_array_serializer.rb', line 17 def deserialize(array) case array # Needed for legacy data. 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 |
# File 'lib/paper_trail/type_serializers/postgres_array_serializer.rb', line 13 def serialize(array) array end |