Class: PaperTrail::AttributeSerializers::ObjectAttribute

Inherits:
Object
  • Object
show all
Defined in:
lib/paper_trail/attribute_serializers/object_attribute.rb

Overview

Serialize or deserialize the ‘version.object` column.

Instance Method Summary collapse

Constructor Details

#initialize(model_class) ⇒ ObjectAttribute

Returns a new instance of ObjectAttribute.



9
10
11
12
13
14
15
16
17
# File 'lib/paper_trail/attribute_serializers/object_attribute.rb', line 9

def initialize(model_class)
  @model_class = model_class

  # ActiveRecord since 7.0 has a built-in encryption mechanism
  @encrypted_attributes =
    if PaperTrail.active_record_gte_7_0?
      @model_class.encrypted_attributes&.map(&:to_s)
    end
end

Instance Method Details

#deserialize(attributes) ⇒ Object



23
24
25
# File 'lib/paper_trail/attribute_serializers/object_attribute.rb', line 23

def deserialize(attributes)
  alter(attributes, :deserialize)
end

#serialize(attributes) ⇒ Object



19
20
21
# File 'lib/paper_trail/attribute_serializers/object_attribute.rb', line 19

def serialize(attributes)
  alter(attributes, :serialize)
end