Module: Komando::Command::Dsl
- Defined in:
- lib/komando/command/dsl.rb
Overview
The Komando DSL. Extend your command classes with this module to start using Komando in your application.
It is recommended you do not implement #initialize in your commands. If you do, you must call super or your parameters will not be available as instance variables.
Instance Method Summary collapse
-
#best_effort_step(name = nil, &block) ⇒ Object
Declares a new best effort step - one that will be executed, but will not stop processing.
-
#best_effort_steps ⇒ Array
Helper method to access the declared blocks.
-
#mandatory_step(name = nil, &block) ⇒ Object
Declares a set of actions that must run to completion for this command to be deemed successful.
-
#mandatory_steps ⇒ Object
Returns the list of mandatory steps.
Instance Method Details
#best_effort_step(name = nil, &block) ⇒ Object
Declares a new best effort step - one that will be executed, but will not stop processing. If the block raises an exception, Komando::Command#run! will log and swallow the exception. Best effort stop blocks have access to the same environment as #mandatory_step blocks - they execute within the same instance. You can pass values from one block to the next by using instance variables.
82 83 84 85 |
# File 'lib/komando/command/dsl.rb', line 82 def best_effort_step(name=nil, &block) @best_effort_steps ||= Array.new @best_effort_steps << [name, block] end |
#best_effort_steps ⇒ Array
Helper method to access the declared blocks.
90 91 92 |
# File 'lib/komando/command/dsl.rb', line 90 def best_effort_steps @best_effort_steps ||= Array.new end |
#mandatory_step(name = nil, &block) ⇒ Object
Declares a set of actions that must run to completion for this command to be deemed successful. The declared actions may be anything: method calls or direct actions. Parameters are passed from the environment as instance variables passed to the instance.
56 57 58 |
# File 'lib/komando/command/dsl.rb', line 56 def mandatory_step(name=nil, &block) mandatory_steps << block end |
#mandatory_steps ⇒ Object
Returns the list of mandatory steps
35 36 37 |
# File 'lib/komando/command/dsl.rb', line 35 def mandatory_steps @mandatory_steps ||= [] end |