Method: AMQ::Client::Async::Exchange#initialize

Defined in:
lib/amq/client/async/exchange.rb

#initialize(connection, channel, name, type = :fanout) ⇒ Exchange

Returns a new instance of Exchange.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/amq/client/async/exchange.rb', line 40

def initialize(connection, channel, name, type = :fanout)
  if !(BUILTIN_TYPES.include?(type.to_sym) || type.to_s =~ /^x-.+/i)
    raise UnknownExchangeTypeError.new(BUILTIN_TYPES, type)
  end

  @connection = connection
  @channel    = channel
  @name       = name
  @type       = type

  # register pre-declared exchanges
  if @name == AMQ::Protocol::EMPTY_STRING || @name =~ /^amq\.(direct|fanout|topic|match|headers)/
    @channel.register_exchange(self)
  end

  super(connection)
end