class MessageDriver::Adapters::BunnyAdapter::ExchangeDestination

Public Instance Methods

after_initialize(adapter_context) click to toggle source
# File lib/message_driver/adapters/bunny_adapter.rb, line 124
def after_initialize(adapter_context)
  if (declare = @dest_options[:declare])
    adapter_context.with_channel(false) do |ch|
      type = declare.delete(:type)
      raise MessageDriver::Error, 'you must provide a valid exchange type' unless type
      ch.exchange_declare(@name, type, declare)
    end
  end
  if (bindings = @dest_options[:bindings])
    adapter_context.with_channel(false) do |ch|
      bindings.each do |bnd|
        raise MessageDriver::Error, "binding #{bnd.inspect} must provide a source!" unless bnd[:source]
        ch.exchange_bind(bnd[:source], @name, bnd[:args] || {})
      end
    end
  end
end