Class: Lite::Command::Sequence

Inherits:
Base
  • Object
show all
Defined in:
lib/lite/command/sequence.rb

Instance Attribute Summary

Attributes inherited from Base

#context

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize

Constructor Details

This class inherits a constructor from Lite::Command::Base

Class Method Details

.step(*commands, **options) ⇒ Object



7
8
9
10
11
# File 'lib/lite/command/sequence.rb', line 7

def self.step(*commands, **options)
  commands.flatten.each do |command|
    steps << Step.new(command, options)
  end
end

.stepsObject



13
14
15
# File 'lib/lite/command/sequence.rb', line 13

def self.steps
  @steps ||= []
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
# File 'lib/lite/command/sequence.rb', line 17

def call
  self.class.steps.each do |step|
    next unless step.run?(self)

    cmd = step.command.call(context)
    throw!(cmd) if cmd.bad?
  end
end