Class: Step
- Inherits:
-
Object
- Object
- Step
- Defined in:
- lib/wrkflo/step.rb
Direct Known Subclasses
Constant Summary collapse
- @@step_map =
A hash of step aliases to their respective classes. This map determines the class that a given step in a project will be transformed into.
{ }
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#name ⇒ Object
Returns the value of attribute name.
-
#project ⇒ Object
Returns the value of attribute project.
Class Method Summary collapse
-
.add_alias(name) ⇒ Object
Add an alias for this class to the step map.
-
.create(name = '', config = {}, project = nil) ⇒ Object
Create a new instance of a Step based on the step map entry.
Instance Method Summary collapse
-
#initialize(name, config, project = nil) ⇒ Step
constructor
A new instance of Step.
-
#log(message) ⇒ Object
A pass through to this step’s project’s log.
-
#run ⇒ Object
The code to run when running this step normally.
-
#unrun ⇒ Object
The code to run when running this step backwards.
Constructor Details
#initialize(name, config, project = nil) ⇒ Step
Returns a new instance of Step.
22 23 24 25 26 27 28 29 |
# File 'lib/wrkflo/step.rb', line 22 def initialize name, config, project=nil # The name for this step @name = name # The options that define this step @config = config # The project that this step belongs to @project = project end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
2 3 4 |
# File 'lib/wrkflo/step.rb', line 2 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/wrkflo/step.rb', line 2 def name @name end |
#project ⇒ Object
Returns the value of attribute project.
2 3 4 |
# File 'lib/wrkflo/step.rb', line 2 def project @project end |
Class Method Details
.add_alias(name) ⇒ Object
Add an alias for this class to the step map. Used by subclasses to register their definitions
11 12 13 |
# File 'lib/wrkflo/step.rb', line 11 def add_alias name @@step_map[name.to_sym] = self end |
.create(name = '', config = {}, project = nil) ⇒ Object
Create a new instance of a Step based on the step map entry. If none exists, a generic Step is created.
17 18 19 |
# File 'lib/wrkflo/step.rb', line 17 def create name='', config={}, project=nil @@step_map[name.to_sym].new(name, config, project) or Step.new(name, config, project) end |
Instance Method Details
#log(message) ⇒ Object
A pass through to this step’s project’s log. If this step has no project, a simple puts call is used instead.
33 34 35 |
# File 'lib/wrkflo/step.rb', line 33 def log @project ? @project.log() : puts() end |
#run ⇒ Object
The code to run when running this step normally
43 44 45 |
# File 'lib/wrkflo/step.rb', line 43 def run log "Nothing to do." end |
#unrun ⇒ Object
The code to run when running this step backwards
47 48 49 |
# File 'lib/wrkflo/step.rb', line 47 def unrun log "Nothing to do." end |