Class: FlowBase
- Inherits:
-
Object
- Object
- FlowBase
- Defined in:
- lib/flow/flow_base.rb
Overview
A flow is a collection of procedurally executed operations sharing a common state.
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
- .inherited(base) ⇒ Object
- .operations(*operations) ⇒ Object
- .state_class ⇒ Object
- .trigger(*arguments) ⇒ Object
Instance Method Summary collapse
-
#initialize(**input) ⇒ FlowBase
constructor
A new instance of FlowBase.
- #trigger ⇒ Object
Constructor Details
#initialize(**input) ⇒ FlowBase
Returns a new instance of FlowBase.
30 31 32 |
# File 'lib/flow/flow_base.rb', line 30 def initialize(**input) @state = state_class.new(**input) end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
26 27 28 |
# File 'lib/flow/flow_base.rb', line 26 def state @state end |
Class Method Details
.inherited(base) ⇒ Object
20 21 22 23 |
# File 'lib/flow/flow_base.rb', line 20 def inherited(base) base._operations = _operations.dup super end |
.operations(*operations) ⇒ Object
16 17 18 |
# File 'lib/flow/flow_base.rb', line 16 def operations(*operations) _operations.concat(operations.flatten) end |
.state_class ⇒ Object
8 9 10 |
# File 'lib/flow/flow_base.rb', line 8 def state_class "#{name.chomp("Flow")}State".constantize end |
.trigger(*arguments) ⇒ Object
12 13 14 |
# File 'lib/flow/flow_base.rb', line 12 def trigger(*arguments) new(*arguments).trigger end |
Instance Method Details
#trigger ⇒ Object
34 35 36 37 |
# File 'lib/flow/flow_base.rb', line 34 def trigger _operations.each { |operation| operation.execute(state) } state end |