Module: PaperTrailDiff::ActivityRootSteps

Defined in:
lib/paper_trail_diff/activity_root_steps.rb,
sig/generated/paper_trail_diff/activity_root_steps.rbs

Overview

Root checkpoint steps recovered from the snapshots an activity pass retained, so a combined result does not reconstruct the same boundaries twice.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(plan, root_snapshots, closing_snapshot: nil, captured_at: nil) ⇒ Object

A window closing on current state ends at the live record, which no version-keyed snapshot can supply, so that endpoint is passed in.

Signature:

  • (RootVersionPlan, Hash[Array[untyped], RecordSnapshot?], ?closing_snapshot: RecordSnapshot?, ?captured_at: untyped) -> Array[Step]



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/paper_trail_diff/activity_root_steps.rb', line 13

def call(plan, root_snapshots, closing_snapshot: nil, captured_at: nil)
  plan.steps.map do |from_endpoint, to_endpoint|
    Step.new(
      from_version: from_endpoint,
      to_version: to_endpoint,
      captured_at: captured_at,
      diff: Engine.compare(
        root_snapshots[version_key(from_endpoint)],
        snapshot_for(to_endpoint, root_snapshots, closing_snapshot)
      )
    )
  end.freeze
end

.snapshot_for(endpoint, root_snapshots, closing_snapshot) ⇒ Object

Signature:

  • (untyped, Hash[Array[untyped], RecordSnapshot?], RecordSnapshot?) -> RecordSnapshot?



28
29
30
31
32
# File 'lib/paper_trail_diff/activity_root_steps.rb', line 28

def snapshot_for(endpoint, root_snapshots, closing_snapshot)
  return closing_snapshot if Endpoint.record?(endpoint)

  root_snapshots[version_key(endpoint)]
end

.version_key(version) ⇒ Object

Signature:

  • (untyped) -> Array[untyped]



35
36
37
# File 'lib/paper_trail_diff/activity_root_steps.rb', line 35

def version_key(version)
  [version.class.name, version.id]
end

Instance Method Details

#self?.callArray[Step]

A window closing on current state ends at the live record, which no version-keyed snapshot can supply, so that endpoint is passed in. : (RootVersionPlan, Hash[Array[untyped], RecordSnapshot?], ?closing_snapshot: RecordSnapshot?, ?captured_at: untyped) -> Array

Parameters:

Returns:



10
# File 'sig/generated/paper_trail_diff/activity_root_steps.rbs', line 10

def self?.call: (RootVersionPlan, Hash[Array[untyped], RecordSnapshot?], ?closing_snapshot: RecordSnapshot?, ?captured_at: untyped) -> Array[Step]

#self?.snapshot_forRecordSnapshot?

: (untyped, Hash[Array[untyped], RecordSnapshot?], RecordSnapshot?) -> RecordSnapshot?

Parameters:

Returns:



13
# File 'sig/generated/paper_trail_diff/activity_root_steps.rbs', line 13

def self?.snapshot_for: (untyped, Hash[Array[untyped], RecordSnapshot?], RecordSnapshot?) -> RecordSnapshot?

#self?.version_keyArray[untyped]

: (untyped) -> Array

Parameters:

  • (Object)

Returns:

  • (Array[untyped])


16
# File 'sig/generated/paper_trail_diff/activity_root_steps.rbs', line 16

def self?.version_key: (untyped) -> Array[untyped]