Class: CallSheet::Transaction
- Inherits:
-
Object
- Object
- CallSheet::Transaction
- Includes:
- Deterministic::Prelude::Result
- Defined in:
- lib/call_sheet/transaction.rb
Instance Method Summary collapse
- #call(input, options = {}) ⇒ Object (also: #[])
-
#initialize(steps) ⇒ Transaction
constructor
private
A new instance of Transaction.
- #subscribe(listeners) ⇒ Object
Constructor Details
#initialize(steps) ⇒ Transaction
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.
Returns a new instance of Transaction.
10 11 12 |
# File 'lib/call_sheet/transaction.rb', line 10 def initialize(steps) @steps = steps end |
Instance Method Details
#call(input, options = {}) ⇒ Object Also known as: []
15 16 17 18 19 20 21 |
# File 'lib/call_sheet/transaction.rb', line 15 def call(input, = {}) () () steps = () steps.inject(Success(input), :>>) end |
#subscribe(listeners) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/call_sheet/transaction.rb', line 25 def subscribe(listeners) if listeners.is_a?(Hash) listeners.each do |step_name, listener| steps.detect { |step| step.step_name == step_name }.subscribe(listener) end else steps.each do |step| step.subscribe(listeners) end end self end |