Class: Qpid::Proton::Handler::Adapter

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

Overview

Base adapter for raw proton events

Direct Known Subclasses

MessagingAdapter, ReactorMessagingAdapter

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h) ⇒ Adapter

Returns a new instance of Adapter.



55
# File 'lib/handler/adapter.rb', line 55

def initialize(h) @handler = h; end

Class Method Details

.adapt(handler)

Create and return an adapter for handler, or return h if it does not need adapting.



58
59
60
61
62
63
64
# File 'lib/handler/adapter.rb', line 58

def self.adapt(handler)
  return unless handler
  a = Array(handler)
  h = (a.size == 1) ? a[0] : ArrayHandler.new(a)
  ac = adapter(h)
  ac ? ac.new(h) : h
end

.adapter(handler)

Adapter class if requested by handler, else default to MessagingHandler



67
68
69
# File 'lib/handler/adapter.rb', line 67

def self.adapter(handler)
  handler.respond_to?(:proton_adapter_class) ? handler.proton_adapter_class : MessagingAdapter
end

Instance Method Details

#forward(method, *args)



73
74
75
# File 'lib/handler/adapter.rb', line 73

def forward(method, *args)
  (@handler.__send__(method, *args); true) if @handler.respond_to? method
end

#proton_adapter_class

Adapters don’t need adapting



71
# File 'lib/handler/adapter.rb', line 71

def proton_adapter_class() nil; end