Class: UI::Sequence
- Inherits:
-
Object
- Object
- UI::Sequence
- Includes:
- Yast::I18n
- Defined in:
- library/sequencer/src/lib/ui/sequence.rb
Overview
A Sequence is an object-oriented interface for the good old Yast::Sequencer. In the simple case it runs a sequence of dialogs connected by Back and Next buttons.
Constant Summary collapse
- START =
A reserved name in the sequence hash to mark the graph entry point.
"ws_start".freeze
Class Method Summary collapse
-
.run(aliases, sequence) ⇒ Object
A drop-in replacement for Yast::Sequencer.Run.
-
.skip_stack(name) ⇒ Object
Declare that a method is skipped when going :back, useful for noninteractive steps.
- .skip_stack?(name) ⇒ Boolean private
Instance Method Summary collapse
-
#abortable(sequence_hash) ⇒ Object
Add {abort: :abort} transitions if missing (an :abort from a dialog should :abort the whole sequence).
-
#from_methods(sequence_hash) ⇒ Hash{String => Proc}
Make
aliases
fromsequence_hash
assuming there is a method for each alias. -
#run(sequence:, aliases: nil) ⇒ Object
A replacement for Yast::Sequencer.Run but smarter: - auto :abort (see #abortable) - aliases are assumed to be method names if unspecified (see #from_methods).
Class Method Details
.run(aliases, sequence) ⇒ Object
A drop-in replacement for Yast::Sequencer.Run
80 81 82 |
# File 'library/sequencer/src/lib/ui/sequence.rb', line 80 def self.run(aliases, sequence) Yast::Sequencer.Run(aliases, sequence) end |
.skip_stack(name) ⇒ Object
Declare that a method is skipped when going :back, useful for noninteractive steps. (also see Yast::SequencerClass#WS_special)
152 153 154 155 |
# File 'library/sequencer/src/lib/ui/sequence.rb', line 152 def skip_stack(name) @skip_stack ||= {} @skip_stack[name.to_sym] = true end |
.skip_stack?(name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
160 161 162 163 |
# File 'library/sequencer/src/lib/ui/sequence.rb', line 160 def skip_stack?(name) @skip_stack ||= {} @skip_stack[name.to_sym] end |
Instance Method Details
#abortable(sequence_hash) ⇒ Object
Add {abort: :abort} transitions if missing (an :abort from a dialog should :abort the whole sequence)
122 123 124 125 126 127 128 129 130 |
# File 'library/sequencer/src/lib/ui/sequence.rb', line 122 def abortable(sequence_hash) sequence_hash.map do |name, destination| if name == START [name, destination] else [name, { abort: :abort }.merge(destination)] end end.to_h end |
#from_methods(sequence_hash) ⇒ Hash{String => Proc}
Make aliases
from sequence_hash
assuming there is a method
for each alias.
135 136 137 138 139 140 141 142 143 144 145 |
# File 'library/sequencer/src/lib/ui/sequence.rb', line 135 def from_methods(sequence_hash) sequence_hash.keys.map do |name| next nil if name == START if self.class.skip_stack?(name) [name, [method(name), true]] else [name, method(name)] end end.compact.to_h end |
#run(sequence:, aliases: nil) ⇒ Object
A replacement for Yast::Sequencer.Run but smarter:
- auto :abort (see #abortable)
- aliases are assumed to be method names if unspecified (see #from_methods)
102 103 104 105 |
# File 'library/sequencer/src/lib/ui/sequence.rb', line 102 def run(sequence:, aliases: nil) aliases ||= from_methods(sequence) self.class.run(aliases, abortable(sequence)) end |