Class: AttemptAdapter

Inherits:
Dry::Transaction::StepAdapters
  • Object
show all
Includes:
Dry::Monads::Either::Mixin
Defined in:
lib/pelita/operation/attempt_adapter.rb

Instance Method Summary collapse

Instance Method Details

#call(step, input, *args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/pelita/operation/attempt_adapter.rb', line 4

def call(step, input, *args)
  unless step.options[:catch]
    raise ArgumentError, "+attempt+ steps require one or more exception classes provided via +catch:+"
  end

  step.operation.call(input, *args)
rescue *Array(step.options[:catch]) => e
  e = step.options[:raise].new(e.message) if step.options[:raise]
  input["error"] = e
  Left(input)
end