Class: Djinn::Base::Dsl::DslDefinitionHelper
- Inherits:
-
Object
- Object
- Djinn::Base::Dsl::DslDefinitionHelper
- Defined in:
- lib/djinn/base/dsl.rb
Overview
A helper class for interpretting the definition block of a Djinn
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#config_helper ⇒ Object
Returns the value of attribute config_helper.
Instance Method Summary collapse
-
#configure(&block) ⇒ Object
Define configuration for a Djinn, adding ARGV switches that can be interpreted and acted on in your actions.
-
#exit(&block) ⇒ Object
Runs when Djinn exits.
-
#initialize(&block) ⇒ DslDefinitionHelper
constructor
A new instance of DslDefinitionHelper.
-
#prepare(config) ⇒ Object
Prepare the Djinn configuration based on informations passed in in the configuration block.
-
#start(&block) ⇒ Object
Runs when the Djinn starts.
-
#stop(&block) ⇒ Object
Runs when the Djinn stops.
Constructor Details
#initialize(&block) ⇒ DslDefinitionHelper
Returns a new instance of DslDefinitionHelper.
162 163 164 165 166 167 |
# File 'lib/djinn/base/dsl.rb', line 162 def initialize &block @actions = {} instance_eval(&block) if block_given? # create in case there was no configuration block @config_helper = ConfigHelper.new unless defined?(@config_helper) end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
160 161 162 |
# File 'lib/djinn/base/dsl.rb', line 160 def actions @actions end |
#config_helper ⇒ Object
Returns the value of attribute config_helper.
160 161 162 |
# File 'lib/djinn/base/dsl.rb', line 160 def config_helper @config_helper end |
Instance Method Details
#configure(&block) ⇒ Object
Define configuration for a Djinn, adding ARGV switches that can be interpreted and acted on in your actions
171 172 173 |
# File 'lib/djinn/base/dsl.rb', line 171 def configure &block @config_helper = ConfigHelper.new(&block) end |
#exit(&block) ⇒ Object
Runs when Djinn exits
181 182 183 |
# File 'lib/djinn/base/dsl.rb', line 181 def exit &block @actions[:exit] = block end |
#prepare(config) ⇒ Object
Prepare the Djinn configuration based on informations passed in in the configuration block
192 193 194 |
# File 'lib/djinn/base/dsl.rb', line 192 def prepare(config) @config_helper.parse_config!(config) end |
#start(&block) ⇒ Object
Runs when the Djinn starts
176 177 178 |
# File 'lib/djinn/base/dsl.rb', line 176 def start &block @actions[:start] = block end |
#stop(&block) ⇒ Object
Runs when the Djinn stops
186 187 188 |
# File 'lib/djinn/base/dsl.rb', line 186 def stop &block @actions[:stop] = block end |