Module: Teckel::Chain::ClassMethods
- Defined in:
- lib/teckel/chain.rb
Instance Method Summary collapse
-
#call(input = nil) ⇒ Teckel::Chain::Result
The primary interface to call the chain with the given input.
-
#errors ⇒ <Class>
List of all possible errors.
-
#input ⇒ Class
The expected input for this chain.
-
#output ⇒ Class
The expected output for this chain.
- #with(settings) ⇒ Object (also: #set)
Instance Method Details
#call(input = nil) ⇒ Teckel::Chain::Result
The primary interface to call the chain with the given input.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/teckel/chain.rb', line 47 def call(input = nil) default_settings = self.default_settings runner = if default_settings self.runner.new(self, default_settings) else self.runner.new(self) end if around around.call(runner, input) else runner.call(input) end end |
#errors ⇒ <Class>
List of all possible errors
34 35 36 37 38 39 |
# File 'lib/teckel/chain.rb', line 34 def errors steps.each_with_object([]) do |step, m| err = step.operation.error m << err if err end end |
#input ⇒ Class
The expected input for this chain
22 23 24 |
# File 'lib/teckel/chain.rb', line 22 def input steps.first&.operation&.input end |
#output ⇒ Class
The expected output for this chain
28 29 30 |
# File 'lib/teckel/chain.rb', line 28 def output steps.last&.operation&.output end |
#with(settings) ⇒ Object Also known as: set
65 66 67 68 69 70 71 72 |
# File 'lib/teckel/chain.rb', line 65 def with(settings) runner = self.runner.new(self, settings) if around ->(input) { around.call(runner, input) } else runner end end |