# File lib/amqp/exchange.rb, line 229 def initialize(mq, type, name, opts = {}, &block) @mq = mq @type, @opts = type, opts @opts = self.class.add_default_options(type, name, opts, block) @key = opts[:key] @name = name unless name.empty? @status = :unknown # The AMQP 0.8 specification (as well as 0.9.1) in 1.1.4.2 mentiones # that Exchange.Declare-Ok confirms the name of the exchange (because # of automaticallynamed), which is logical to interpret that this # functionality should be the same as for Queue (though it isn't # explicitely told in the specification). In fact, RabbitMQ (and # probably other implementations as well) doesn't support it and # there is a default exchange with an empty name (so-called default # or nameless exchange), so if we'd send Exchange.Declare(exchange=""), # then RabbitMQ interpret it as if we'd try to redefine this default # exchange so it'd produce an error. unless name == "amq.#{type}" or name == '' or opts[:no_declare] @status = :unfinished @mq.callback { @mq.send Protocol::Exchange::Declare.new(@opts) } else # Call the callback immediately, as given exchange is already # declared. @status = :finished block.call(self) if block end self.callback = block end