Class: Transflow::Transaction
- Inherits:
-
Object
- Object
- Transflow::Transaction
- Defined in:
- lib/transflow/transaction.rb
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #call(*args) ⇒ Object (also: #[])
-
#initialize(steps, handler) ⇒ Transaction
constructor
A new instance of Transaction.
- #subscribe(listeners) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(steps, handler) ⇒ Transaction
Returns a new instance of Transaction.
22 23 24 25 |
# File 'lib/transflow/transaction.rb', line 22 def initialize(steps, handler) @steps = steps @handler = handler end |
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
18 19 20 |
# File 'lib/transflow/transaction.rb', line 18 def handler @handler end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
20 21 22 |
# File 'lib/transflow/transaction.rb', line 20 def steps @steps end |
Instance Method Details
#call(*args) ⇒ Object Also known as: []
31 32 33 34 35 |
# File 'lib/transflow/transaction.rb', line 31 def call(*args) handler.call(*args) rescue Transproc::MalformedInputError => err raise TransactionFailedError.new(self, err) end |
#subscribe(listeners) ⇒ Object
27 28 29 |
# File 'lib/transflow/transaction.rb', line 27 def subscribe(listeners) listeners.each { |step, listener| steps[step].subscribe(listener) } end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/transflow/transaction.rb', line 38 def to_s "Transaction(#{steps.keys.join(' => ')})" end |