Class: MARS::Workflows::Sequential
- Defined in:
- lib/mars/workflows/sequential.rb
Instance Attribute Summary
Attributes inherited from Runnable
Instance Method Summary collapse
-
#initialize(name, steps:, **kwargs) ⇒ Sequential
constructor
A new instance of Sequential.
- #run(context) ⇒ Object
Methods inherited from Runnable
Methods included from Hooks
included, #run_after_hooks, #run_before_hooks
Constructor Details
#initialize(name, steps:, **kwargs) ⇒ Sequential
Returns a new instance of Sequential.
6 7 8 9 10 |
# File 'lib/mars/workflows/sequential.rb', line 6 def initialize(name, steps:, **kwargs) super(name: name, **kwargs) @steps = steps end |
Instance Method Details
#run(context) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mars/workflows/sequential.rb', line 12 def run(context) context = ensure_context(context) @steps.each do |step| step.run_before_hooks(context) step_input = step.formatter.format_input(context) context.current_input = step_input result = step.run(context) formatted = step.formatter.format_output(result) context.record(step.name, formatted) step.run_after_hooks(context, formatted) end context.current_input end |