Class: Qpid::Proton::Handler::ArrayHandler

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

Overview

Handler for an array of handlers of uniform type, with non-conflicting options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handlers) ⇒ ArrayHandler

Returns a new instance of ArrayHandler.



28
29
30
31
32
33
34
35
36
37
# File 'lib/handler/adapter.rb', line 28

def initialize(handlers)
  raise "empty handler array" if handlers.empty?
  adapters = (handlers.map { |h| Adapter.adapter(h) }).uniq
  raise "handler array not uniform, adapters requested: #{adapters}" if adapters.size > 1
  @proton_adapter_class = adapters[0]
  @methods = Set.new
  handlers.each do |h|
    @methods.merge(h.methods.select { |m| handler_method? m }) # Collect handler methods
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args)



41
42
43
44
45
46
47
# File 'lib/handler/adapter.rb', line 41

def method_missing(name, *args)
  if respond_to_missing?(name)
    @adapters.each { |a| a.__send__(name, *args) if a.respond_to? name}
  else
    super
  end
end

Instance Attribute Details

#options (readonly)



39
40
41
# File 'lib/handler/adapter.rb', line 39

def options
  @options
end

#proton_adapter_class (readonly)



39
40
41
# File 'lib/handler/adapter.rb', line 39

def proton_adapter_class
  @proton_adapter_class
end

Instance Method Details

#respond_to?(name, all = false) ⇒ Boolean

For ruby < 1.9.2

Returns:

  • (Boolean)


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

def respond_to?(name, all=false) super || respond_to_missing?(name); end

#respond_to_missing?(name, private = false) ⇒ Boolean

Returns:

  • (Boolean)


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

def respond_to_missing?(name, private=false); @methods.include?(name); end