Class: Eco::API::UseCases::GraphQL::Compat::Parity::Harness::Recorder

Inherits:
Object
  • Object
show all
Defined in:
lib/eco/api/usecases/graphql/compat/parity/harness.rb

Overview

Collects a run's KPIs + per-page update payloads, then bakes a RunResult.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label) ⇒ Recorder

Returns a new instance of Recorder.



77
78
79
80
81
# File 'lib/eco/api/usecases/graphql/compat/parity/harness.rb', line 77

def initialize(label)
  @label   = label
  @kpis    = {}
  @updates = {}
end

Instance Attribute Details

#kpisObject

Returns the value of attribute kpis.



75
76
77
# File 'lib/eco/api/usecases/graphql/compat/parity/harness.rb', line 75

def kpis
  @kpis
end

Instance Method Details

#kpi(name, value) ⇒ Object

Set a single canonical/native KPI counter by name.



91
92
93
94
# File 'lib/eco/api/usecases/graphql/compat/parity/harness.rb', line 91

def kpi(name, value)
  @kpis[name.to_sym] = value
  self
end

#record_update(page_id, payload) ⇒ Object

Record what a run WOULD send for page_id. Later ids for the same page overwrite (the last state wins — matching a real save of the final page).



85
86
87
88
# File 'lib/eco/api/usecases/graphql/compat/parity/harness.rb', line 85

def record_update(page_id, payload)
  @updates[page_id.to_s] = payload
  self
end

#to_run_resultObject



96
97
98
# File 'lib/eco/api/usecases/graphql/compat/parity/harness.rb', line 96

def to_run_result
  RunResult.new(label: @label, kpis: @kpis, updates: @updates)
end