Class: PaperTrail::AttributeSerializers::ObjectChangesAttribute

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

Overview

Serialize or deserialize the ‘version.object_changes` column.

Instance Method Summary collapse

Constructor Details

#initialize(item_class) ⇒ ObjectChangesAttribute

Returns a new instance of ObjectChangesAttribute.



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

def initialize(item_class)
  @item_class = item_class

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

Instance Method Details

#deserialize(changes) ⇒ Object



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

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

#serialize(changes) ⇒ Object



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

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