Class: Qpid::Proton::Handler::CAdaptor

Inherits:
Object
  • Object
show all
Defined in:
lib/handler/c_adaptor.rb

Instance Method Summary collapse

Constructor Details

#initialize(handler, on_error = nil) ⇒ CAdaptor

Returns a new instance of CAdaptor.



25
26
27
28
# File 'lib/handler/c_adaptor.rb', line 25

def initialize(handler, on_error = nil)
  @handler = handler
  @on_error = on_error
end

Instance Method Details

#dispatch(cevent, ctype) ⇒ Object



30
31
32
33
34
35
# File 'lib/handler/c_adaptor.rb', line 30

def dispatch(cevent, ctype)
  event = Qpid::Proton::Event::Event.wrap(cevent, ctype)
  # TODO add a variable to enable this programmatically
  # print "EVENT: #{event} going to #{@handler}\n"
  event.dispatch(@handler)
end

#exception(error) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/handler/c_adaptor.rb', line 37

def exception(error)
  if @on_error.nil?
    raise error
  else
    @on_error.call(error)
  end
end