Class: Course::Operation
- Inherits:
-
Object
- Object
- Course::Operation
- Defined in:
- lib/course/operation.rb
Class Method Summary collapse
- .call(*input, &block) ⇒ Object
- .inherited(child) ⇒ Object
- .step(name = nil, **options, &block) ⇒ Object
- .steps ⇒ Object
Instance Method Summary collapse
Class Method Details
.call(*input, &block) ⇒ Object
6 7 8 |
# File 'lib/course/operation.rb', line 6 def call(*input, &block) new.call(*input, &block) end |
.inherited(child) ⇒ Object
18 19 20 |
# File 'lib/course/operation.rb', line 18 def inherited(child) child.instance_variable_set('@steps', @steps.clone) end |
.step(name = nil, **options, &block) ⇒ Object
10 11 12 |
# File 'lib/course/operation.rb', line 10 def step(name = nil, **, &block) steps << Course::Step.new(name, block, **) end |
.steps ⇒ Object
14 15 16 |
# File 'lib/course/operation.rb', line 14 def steps @steps ||= [] end |
Instance Method Details
#call(*input, &block) ⇒ Object
23 24 25 26 27 |
# File 'lib/course/operation.rb', line 23 def call(*input, &block) execute_steps(*input, &block) return yield result if block_given? result end |
#result ⇒ Object
29 30 31 |
# File 'lib/course/operation.rb', line 29 def result Course::Result.new(output: @output, failure: @failure) end |