class Qpid::Proton::Handler::WrappedHandler

Public Class Methods

new(impl_or_constructor) click to toggle source
# File lib/handler/wrapped_handler.rb, line 37
def initialize(impl_or_constructor)
  if impl_or_constructor.is_a?(Method)
    @impl = impl_or_constructor.call
  else
    @impl = impl_or_constructor
    Cproton.pn_incref(@impl)
  end
  @on_error = nil
  self.class.store_instance(self)
end
wrap(impl, on_error = nil) click to toggle source
# File lib/handler/wrapped_handler.rb, line 27
def self.wrap(impl, on_error = nil)
  return nil if impl.nil?

  result = self.fetch_instance(impl) || WrappedHandler.new(impl)
  result.on_error = on_error
  return result
end

Public Instance Methods

add(handler) click to toggle source
# File lib/handler/wrapped_handler.rb, line 48
def add(handler)
  return if handler.nil?

  impl = chandler(handler, self.method(:_on_error))
  Cproton.pn_handler_add(@impl, impl)
  Cproton.pn_decref(impl)
end
clear() click to toggle source
# File lib/handler/wrapped_handler.rb, line 56
def clear
  Cproton.pn_handler_clear(@impl)
end
on_error=(on_error) click to toggle source
# File lib/handler/wrapped_handler.rb, line 60
def on_error=(on_error)
  @on_error = on_error
end

Private Instance Methods

_on_error(info) click to toggle source
# File lib/handler/wrapped_handler.rb, line 66
def _on_error(info)
  if self.has?['on_error']
    self['on_error'].call(info)
  else
    raise info
  end
end