Module: PaperTrail::AttributeSerializers::AttributeSerializerFactory Private

Defined in:
lib/paper_trail/attribute_serializers/attribute_serializer_factory.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

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.

Class Method Summary collapse

Class Method Details

.for(klass, attr) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/paper_trail/attribute_serializers/attribute_serializer_factory.rb', line 16

def for(klass, attr)
  active_record_serializer = klass.type_for_attribute(attr)
  if ar_pg_array?(active_record_serializer)
    TypeSerializers::PostgresArraySerializer.new(
      active_record_serializer.subtype,
      active_record_serializer.delimiter
    )
  else
    active_record_serializer
  end
end