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
-
.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.
- .snapshot_for(endpoint, root_snapshots, closing_snapshot) ⇒ Object
- .version_key(version) ⇒ Object
Instance Method Summary collapse
-
#self?.call ⇒ Array[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.
-
#self?.snapshot_for ⇒ RecordSnapshot?
: (untyped, Hash[Array[untyped], RecordSnapshot?], RecordSnapshot?) -> RecordSnapshot?.
-
#self?.version_key ⇒ Array[untyped]
: (untyped) -> Array.
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.
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
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
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?.call ⇒ Array[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
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_for ⇒ RecordSnapshot?
: (untyped, Hash[Array[untyped], RecordSnapshot?], RecordSnapshot?) -> RecordSnapshot?
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_key ⇒ Array[untyped]
: (untyped) -> Array
16 |
# File 'sig/generated/paper_trail_diff/activity_root_steps.rbs', line 16
def self?.version_key: (untyped) -> Array[untyped]
|