Class: Eventbox::CompletionProc

Inherits:
AsyncProc show all
Defined in:
lib/eventbox/sanitizer.rb

Overview

Proc object provided as the last argument of yield_call and #yield_proc.

Instance Method Summary collapse

Instance Method Details

#raise(*args) ⇒ Object

Raise an exception in the context of the waiting Eventbox.yield_call or Eventbox#yield_proc method.

This allows to raise an exception to the calling scope from external or action scope:

class MyBox < Eventbox
  yield_call def init(result)
    process(result)
  end

  action def process(result)
    result.raise RuntimeError, "raise from action MyBox#process"
  end
end
MyBox.new   # => raises RuntimeError (raise from action MyBox#process)

In contrast to a direct call of `Kernel.raise`, calling this method doesn't abort the current context. Instead when in the event scope, raising the exception is deferred until returning to the calling external or action scope.


305
306
307
# File 'lib/eventbox/sanitizer.rb', line 305

def raise(*args)
  self.call(WrappedException.new(args))
end