Class: Textus::Write::RefreshOrchestrator
- Inherits:
-
Object
- Object
- Textus::Write::RefreshOrchestrator
- Defined in:
- lib/textus/write/refresh_orchestrator.rb
Instance Method Summary collapse
- #execute(action, key:) ⇒ Object
-
#initialize(worker:, store_root:, events:, hook_context: nil, detached_spawner: nil) ⇒ RefreshOrchestrator
constructor
Collaborator (not a Dispatcher verb): constructed directly by RefreshWorker / GetOrRefresh, which pass their derived hook_context in.
Constructor Details
#initialize(worker:, store_root:, events:, hook_context: nil, detached_spawner: nil) ⇒ RefreshOrchestrator
Collaborator (not a Dispatcher verb): constructed directly by RefreshWorker / GetOrRefresh, which pass their derived hook_context in. That’s why this takes hook_context: explicitly while verb use cases derive their own.
7 8 9 10 11 12 13 |
# File 'lib/textus/write/refresh_orchestrator.rb', line 7 def initialize(worker:, store_root:, events:, hook_context: nil, detached_spawner: nil) @worker = worker @store_root = store_root @events = events @hook_context = hook_context @detached_spawner = detached_spawner || default_spawner end |
Instance Method Details
#execute(action, key:) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/textus/write/refresh_orchestrator.rb', line 15 def execute(action, key:) case action when Textus::Domain::Action::Return then Textus::Domain::Outcome::Skipped.new when Textus::Domain::Action::RefreshSync then run_sync(key) when Textus::Domain::Action::RefreshTimed then run_timed(action.budget_ms, key) else raise ArgumentError.new("unknown action: #{action.inspect}") end end |