Module: CMDx::Workflow::ClassMethods
- Defined in:
- lib/cmdx/workflow.rb
Instance Method Summary collapse
- #inherited(subclass) ⇒ void private
-
#pipeline ⇒ Array<ExecutionGroup>
Declared groups, in order.
-
#tasks(*tasks, **options) ⇒ Array<ExecutionGroup>
(also: #task)
Declares a task group.
Instance Method Details
#inherited(subclass) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
17 18 19 20 |
# File 'lib/cmdx/workflow.rb', line 17 def inherited(subclass) super subclass.instance_variable_set(:@pipeline, pipeline.dup) end |
#pipeline ⇒ Array<ExecutionGroup>
Returns declared groups, in order.
23 24 25 |
# File 'lib/cmdx/workflow.rb', line 23 def pipeline @pipeline ||= [] end |
#tasks(*tasks, **options) ⇒ Array<ExecutionGroup> Also known as: task
Declares a task group. With no arguments, returns the pipeline. Tasks must be ‘Task` subclasses.
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/cmdx/workflow.rb', line 61 def tasks(*tasks, **) raise DefinitionError, "#{name}: cannot declare an empty task group" if tasks.empty? pipeline << ExecutionGroup.new( tasks: tasks.map do |task| next task if task.is_a?(Class) && (task <= Task) raise TypeError, "#{task.inspect} is not a Task" end, options: ) end |