Class: Linearly::Step::Static
- Inherits:
-
Object
- Object
- Linearly::Step::Static
- Extended by:
- Mixins::FlowBuilder
- Defined in:
- lib/linearly/step/static.rb
Overview
Static is a type of Step
whose operation solely depends on the content of the State
passed to its Static.call method. It’s the best and most deterministic type of a Step
, hence we provided a helper. Inheriting from Static will still require you to implement three methods: class inputs
and outputs
methods, and an instance call
method. What you get though is that your call
method does not need to take any parameters and will have access to the private state
instance variable. What’s more, any unknown messages will be forwarded to state
, so that your code can be shorter and more expressive. Also, you don’t have to explicitly rescue exceptions - the static Static.call method will catch those and fail the state
accordingly.
Class Method Summary collapse
-
.call(state) ⇒ Statefully::State
Main entry point to Static.
-
.inputs ⇒ Hash<Symbol, Expectation>
Inputs for a step.
-
.outputs ⇒ Hash<Symbol, Expectation>
Outputs for a step.
Instance Method Summary collapse
-
#call ⇒ Statefully::State
private
User-defined logic for this
Step
.
Methods included from Mixins::FlowBuilder
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
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.
Dynamically pass valid inputs to the wrapped State
100 101 102 103 |
# File 'lib/linearly/step/static.rb', line 100 def method_missing(name, *args, &block) allowed = [:correlation_id] + state.methods + self.class.inputs.keys allowed.include?(name) ? state.send(name, *args, &block) : super end |
Class Method Details
.call(state) ⇒ Statefully::State
Main entry point to Linearly::Step::Static
38 39 40 41 42 |
# File 'lib/linearly/step/static.rb', line 38 def self.call(state) new(state).call rescue StandardError => err state.fail(err) end |
.inputs ⇒ Hash<Symbol, Expectation>
Inputs for a step
59 60 61 |
# File 'lib/linearly/step/static.rb', line 59 def self.inputs raise NotImplementedError end |
.outputs ⇒ Hash<Symbol, Expectation>
Outputs for a step
70 71 72 |
# File 'lib/linearly/step/static.rb', line 70 def self.outputs {} end |
Instance Method Details
#call ⇒ Statefully::State
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.
User-defined logic for this Step
48 49 50 |
# File 'lib/linearly/step/static.rb', line 48 def call raise NotImplementedError end |