Class: PaperTrailDiff::Analysis
- Inherits:
-
Object
- Object
- PaperTrailDiff::Analysis
- Defined in:
- lib/paper_trail_diff/analysis.rb,
sig/generated/paper_trail_diff/analysis.rbs
Overview
Endpoint and root-checkpoint timeline results built from one normalized history.
Instance Attribute Summary collapse
- #activity_timeline ⇒ Array[ActivityStep]? readonly
- #diff ⇒ Diff readonly
- #from_snapshot ⇒ RecordSnapshot? readonly
- #timeline ⇒ Array[Step] readonly
- #to_snapshot ⇒ RecordSnapshot? readonly
Class Method Summary collapse
-
.empty ⇒ Analysis
The result for a record whose requested history contains no versions, which is an empty history rather than a failed request.
Instance Method Summary collapse
-
#initialize(diff:, timeline:, activity_timeline: nil, from_snapshot: nil, to_snapshot: nil) ⇒ Analysis
constructor
The reconstructed states the diff was taken between.
-
#to_h(snapshots: false) ⇒ Hash[Symbol, untyped]
Reconstructed endpoint states are opt-in, because they carry the whole selected graph whether or not anything changed, which dwarfs the rest of the payload for a wide graph.
Constructor Details
#initialize(diff:, timeline:, activity_timeline: nil, from_snapshot: nil, to_snapshot: nil) ⇒ Analysis
25 26 27 28 29 30 31 32 |
# File 'lib/paper_trail_diff/analysis.rb', line 25 def initialize(diff:, timeline:, activity_timeline: nil, from_snapshot: nil, to_snapshot: nil) @diff = diff @timeline = timeline.dup.freeze @activity_timeline = activity_timeline&.dup&.freeze @from_snapshot = from_snapshot @to_snapshot = to_snapshot freeze end |
Instance Attribute Details
#activity_timeline ⇒ Array[ActivityStep]? (readonly)
9 10 11 |
# File 'lib/paper_trail_diff/analysis.rb', line 9 def activity_timeline @activity_timeline end |
#from_snapshot ⇒ RecordSnapshot? (readonly)
10 11 12 |
# File 'lib/paper_trail_diff/analysis.rb', line 10 def from_snapshot @from_snapshot end |
#timeline ⇒ Array[Step] (readonly)
8 9 10 |
# File 'lib/paper_trail_diff/analysis.rb', line 8 def timeline @timeline end |
#to_snapshot ⇒ RecordSnapshot? (readonly)
11 12 13 |
# File 'lib/paper_trail_diff/analysis.rb', line 11 def to_snapshot @to_snapshot end |
Class Method Details
.empty ⇒ Analysis
The result for a record whose requested history contains no versions, which is an empty history rather than a failed request. : () -> Analysis
16 17 18 19 20 |
# File 'lib/paper_trail_diff/analysis.rb', line 16 def self.empty timeline = [] #: Array[Step] activity_timeline = [] #: Array[ActivityStep] new(diff: Diff.new, timeline: timeline, activity_timeline: activity_timeline) end |
Instance Method Details
#to_h(snapshots: false) ⇒ Hash[Symbol, untyped]
Reconstructed endpoint states are opt-in, because they carry the whole selected graph whether or not anything changed, which dwarfs the rest of the payload for a wide graph. : (?snapshots: bool) -> Hash[Symbol, untyped]
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/paper_trail_diff/analysis.rb', line 38 def to_h(snapshots: false) value = { diff: diff.to_h, timeline: Support.serialize(timeline) } value[:activity_timeline] = Support.serialize(activity_timeline) if activity_timeline return value unless snapshots value.merge( from_snapshot: Support.serialize(from_snapshot), to_snapshot: Support.serialize(to_snapshot) ) end |