Module: Qpid::Proton::Util::ClassWrapper

Included in:
Event::Event
Defined in:
lib/util/class_wrapper.rb

Overview

This mixin provides a method for mapping from an underlying Proton C library class to a Ruby class.

Constant Summary collapse

WRAPPERS =
{
  "pn_void" => proc {|x| Cproton.pn_void2rb(x)},
  "pn_rbref" => proc {|x| Cproton.pn_void2rb(x)},
  "pn_connection" => proc {|x| Qpid::Proton::Connection.wrap(Cproton.pn_cast_pn_connection(x))},
  "pn_session" => proc {|x| Qpid::Proton::Session.wrap(Cproton.pn_cast_pn_session(x))},
  "pn_link" => proc {|x| Qpid::Proton::Link.wrap(Cproton.pn_cast_pn_link(x))},
  "pn_delivery" => proc {|x| Qpid::Proton::Delivery.wrap(Cproton.pn_cast_pn_delivery(x))},
  "pn_transport" => proc {|x| Qpid::Proton::Transport.wrap(Cproton.pn_cast_pn_transport(x))},
  "pn_selectable" => proc {|x| Qpid::Proton::Selectable.wrap(Cproton.pn_cast_pn_selectable(x))},
  "pn_reactor" => proc {|x| Qpid::Proton::Reactor::Reactor.wrap(Cproton.pn_cast_pn_reactor(x))},
  "pn_task" => proc {|x| Qpid::Proton::Reactor::Task.wrap(Cproton.pn_cast_pn_task(x))},
}

Instance Method Summary collapse

Instance Method Details

#class_wrapper(clazz, c_impl, &block) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/util/class_wrapper.rb', line 43

def class_wrapper(clazz, c_impl, &block)
  proc_func = WRAPPERS[clazz]
  if !proc_func.nil?
    proc_func.yield(c_impl)
  elsif block_given?
    yield(c_impl)
  end
end