Class: Fairway::ChanneledConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/fairway/channeled_connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, &block) ⇒ ChanneledConnection

Returns a new instance of ChanneledConnection.



3
4
5
6
# File 'lib/fairway/channeled_connection.rb', line 3

def initialize(connection, &block)
  @connection = connection
  @block = block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



13
14
15
# File 'lib/fairway/channeled_connection.rb', line 13

def method_missing(method, *args, &block)
  @connection.respond_to?(method) ? @connection.send(method, *args, &block) : super
end

Instance Method Details

#deliver(message) ⇒ Object



8
9
10
11
# File 'lib/fairway/channeled_connection.rb', line 8

def deliver(message)
  channel = @block.call(message)
  @connection.deliver(message, channel)
end