Method: Handle#with

Defined in:
lib/handle.rb

#with(args = {}, &block) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/handle.rb', line 34

def with(args={}, &block)
  args = args.slice(:on_fail)

  if success?
    @returns_pool << block.call(@result.return, **options = {})
    @result.return = @returns_pool.last
  end
  self
rescue StandardError => e
  if args[:on_fail] == :rollback
    @result.return = @returns_pool.last
    self
  else
    error_handler(e)
  end
end