Method: Transflow::Transaction#call

Defined in:
lib/transflow/transaction.rb

#call(input, options = {}) ⇒ Object Also known as: []

Call the transaction

Once transaction is called it will call the first step and its result will be passed to the second step and so on.

Examples:

my_container = {
  add_one: -> i { i + 1 },
  add_two: -> j { j + 2 }
}

transaction = Transflow(container: my_container) {
  step(:one, with: :add_one) { step(:two, with: :add_two) }
}

transaction.call(1) # 4

Parameters:

  • The input for the first step

  • (defaults to: {})

    The curry-args map, optional

Returns:

API:

  • public



110
111
112
113
114
115
# File 'lib/transflow/transaction.rb', line 110

def call(input, options = {})
  handler = handler_steps(options).map(&method(:fn)).reduce(:>>)
  handler.call(input)
rescue Transproc::MalformedInputError => err
  raise TransactionFailedError.new(self, err.original_error)
end