Class: Smith::Workflow::Pipeline
- Inherits:
-
Object
- Object
- Smith::Workflow::Pipeline
- Defined in:
- lib/smith/workflow/pipeline.rb
Instance Attribute Summary collapse
-
#failure_transition ⇒ Object
readonly
Returns the value of attribute failure_transition.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#stages ⇒ Object
readonly
Returns the value of attribute stages.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #compile!(workflow_class) ⇒ Object
-
#initialize(name, from:, to:) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #on_failure(transition_name) ⇒ Object
- #stage(stage_name, execute:) ⇒ Object
Constructor Details
#initialize(name, from:, to:) ⇒ Pipeline
Returns a new instance of Pipeline.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/smith/workflow/pipeline.rb', line 8 def initialize(name, from:, to:, &) raise WorkflowError, "pipeline name is required" if name.nil? raise WorkflowError, "pipeline :#{name} requires from:" if from.nil? raise WorkflowError, "pipeline :#{name} requires to:" if to.nil? @name = name @from = from @to = to @stages = [] @failure_transition = nil instance_eval(&) end |
Instance Attribute Details
#failure_transition ⇒ Object (readonly)
Returns the value of attribute failure_transition.
6 7 8 |
# File 'lib/smith/workflow/pipeline.rb', line 6 def failure_transition @failure_transition end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
6 7 8 |
# File 'lib/smith/workflow/pipeline.rb', line 6 def from @from end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/smith/workflow/pipeline.rb', line 6 def name @name end |
#stages ⇒ Object (readonly)
Returns the value of attribute stages.
6 7 8 |
# File 'lib/smith/workflow/pipeline.rb', line 6 def stages @stages end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
6 7 8 |
# File 'lib/smith/workflow/pipeline.rb', line 6 def to @to end |
Instance Method Details
#compile!(workflow_class) ⇒ Object
32 33 34 35 36 |
# File 'lib/smith/workflow/pipeline.rb', line 32 def compile!(workflow_class) validate! validate_no_collisions!(workflow_class) generate_transitions(workflow_class) end |
#on_failure(transition_name) ⇒ Object
28 29 30 |
# File 'lib/smith/workflow/pipeline.rb', line 28 def on_failure(transition_name) @failure_transition = transition_name end |
#stage(stage_name, execute:) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/smith/workflow/pipeline.rb', line 21 def stage(stage_name, execute:) raise WorkflowError, "pipeline :#{name} stage name is required" if stage_name.nil? raise WorkflowError, "pipeline :#{name} stage :#{stage_name} requires execute:" if execute.nil? @stages << { name: stage_name, agent: execute } end |