Class: PaperTrailDiff::TimelineSnapshotProvider

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

Overview

Gives TimelineBuilder one-argument access to a range-prepared snapshot store.

Instance Method Summary collapse

Constructor Details

#initialize(store, live_snapshotter:) ⇒ TimelineSnapshotProvider

: (HistoricalSnapshotStore, live_snapshotter: untyped) -> void

Parameters:



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

def initialize(store, live_snapshotter:)
  @store = store
  @live_snapshotter = live_snapshotter
end

Instance Method Details

#call(endpoint) ⇒ RecordSnapshot?

A window closing on current state ends at the live record rather than at a version, which is the one endpoint no version history can reconstruct. : (untyped) -> RecordSnapshot?

Parameters:

  • (Object)

Returns:



21
22
23
24
25
# File 'lib/paper_trail_diff/timeline_snapshot_provider.rb', line 21

def call(endpoint)
  return live_snapshot(endpoint) if Endpoint.record?(endpoint)

  @store.uncached(endpoint, endpoint)
end

#live_snapshot(record) ⇒ RecordSnapshot?

: (untyped) -> RecordSnapshot?

Parameters:

  • (Object)

Returns:



30
31
32
# File 'lib/paper_trail_diff/timeline_snapshot_provider.rb', line 30

def live_snapshot(record)
  @live_snapshotter.call(record)
end

#prepare(record, versions) ⇒ void

This method returns an undefined value.

: (untyped, Array) -> void

Parameters:

  • (Object)
  • (Array[untyped])


14
15
16
# File 'lib/paper_trail_diff/timeline_snapshot_provider.rb', line 14

def prepare(record, versions)
  @store.prepare(record, versions)
end