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. At least one ‘Task` subclass is required —invoking with no arguments raises `DefinitionError`. Use #pipeline to read the existing group list.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/cmdx/workflow.rb', line 62 def tasks(*tasks, **) if tasks.empty? raise DefinitionError, <<~MSG.chomp #{name}: cannot declare an empty task group; pass at least one Task subclass. See https://drexed.github.io/cmdx/workflows/#declarations MSG end pipeline << ExecutionGroup.new( tasks: tasks.map do |task| next task if task.is_a?(Class) && (task <= Task) raise TypeError, <<~MSG.chomp #{task.inspect} is not a Task subclass. See https://drexed.github.io/cmdx/workflows/#declarations MSG end, options: ) end |