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.



106
107
108
109
110
# File 'lib/clacky/ui_interface.rb', line 106

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



117
118
119
120
121
# File 'lib/clacky/ui_interface.rb', line 117

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



112
113
114
115
# File 'lib/clacky/ui_interface.rb', line 112

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