Class: PaperTrailDiff::CollectionTransition

Inherits:
Object
  • Object
show all
Defined in:
lib/paper_trail_diff/collection_transition.rb,
sig/generated/paper_trail_diff/collection_transition.rbs

Overview

One collection mutation between structurally adjacent snapshots.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, before:, after:) ⇒ CollectionTransition

The origin is recorded by serial rather than by reference, because holding it would retain every earlier snapshot at the same path for the whole timeline. : (from: AssociationSnapshot, before: RecordSnapshot?, after: RecordSnapshot?) -> void

Parameters:



14
15
16
17
18
19
# File 'lib/paper_trail_diff/collection_transition.rb', line 14

def initialize(from:, before:, after:)
  @from_serial = from.serial
  @before = before
  @after = after
  freeze
end

Instance Attribute Details

#afterRecordSnapshot? (readonly)

Signature:

  • RecordSnapshot?

Returns:



8
9
10
# File 'lib/paper_trail_diff/collection_transition.rb', line 8

def after
  @after
end

#beforeRecordSnapshot? (readonly)

Signature:

  • RecordSnapshot?

Returns:



7
8
9
# File 'lib/paper_trail_diff/collection_transition.rb', line 7

def before
  @before
end

Instance Method Details

#from?(association) ⇒ Boolean

: (AssociationSnapshot) -> bool

Parameters:

Returns:

  • (Boolean)


22
23
24
# File 'lib/paper_trail_diff/collection_transition.rb', line 22

def from?(association)
  @from_serial == association.serial
end