Class: Clacky::UIInterface::LegacyProgressHandleAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/clacky/ui_interface.rb

Overview

Minimal adapter that lets UIs without a native ProgressHandle still participate in the new with_progress API by delegating to the old show_progress(phase: …) contract. UI2::UIController overrides start_progress directly with a native ProgressHandle, so this adapter is only used by plain/json/web/channel UIs.

Instance Method Summary collapse

Constructor Details

#initialize(ui, progress_type:) ⇒ LegacyProgressHandleAdapter

Returns a new instance of LegacyProgressHandleAdapter.



89
90
91
92
93
# File 'lib/clacky/ui_interface.rb', line 89

def initialize(ui, progress_type:)
  @ui = ui
  @progress_type = progress_type
  @closed = false
end

Instance Method Details

#finish(final_message: nil) ⇒ Object Also known as: cancel



100
101
102
103
104
# File 'lib/clacky/ui_interface.rb', line 100

def finish(final_message: nil)
  return if @closed
  @closed = true
  @ui.show_progress(final_message, progress_type: @progress_type, phase: "done")
end

#update(message: nil, metadata: nil) ⇒ Object



95
96
97
98
# File 'lib/clacky/ui_interface.rb', line 95

def update(message: nil, metadata: nil)
  return if @closed
  @ui.show_progress(message, progress_type: @progress_type, phase: "active", metadata:  || {})
end