Module: PaperTrail::AttributeSerializers::AttributeSerializerFactory
- Defined in:
- lib/paper_trail/attribute_serializers/attribute_serializer_factory.rb
Overview
Values returned by some Active Record serializers are not suited for writing JSON to a text column. This factory replaces certain default Active Record serializers with custom PaperTrail ones.
Constant Summary collapse
- AR_PG_ARRAY_CLASS =
"ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array"
Class Method Summary collapse
Class Method Details
.for(klass, attr) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/paper_trail/attribute_serializers/attribute_serializer_factory.rb', line 14 def self.for(klass, attr) active_record_serializer = klass.type_for_attribute(attr) if active_record_serializer.class.name == AR_PG_ARRAY_CLASS TypeSerializers::PostgresArraySerializer.new( active_record_serializer.subtype, active_record_serializer.delimiter ) else active_record_serializer end end |