Module: RabbitMQSpec::Setup::WorldSetupper Private

Defined in:
lib/rabbitmq-spec/setup/world_setupper.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

It uses the client to configure the RabbitMQ according with the world object

Examples:

RabbitMQSpec::Setup::WorldSetupper.(world, client)

Class Method Summary collapse

Class Method Details

.call(world, client) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
# File 'lib/rabbitmq-spec/setup/world_setupper.rb', line 8

def call(world, client)
  world.exchanges.each do |exchange|
    setup_exchange(exchange, client)
  end
  world.single_queues.each do |queue|
    setup_queue(queue, client)
  end
end

.setup_exchange(exchange, client) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rabbitmq-spec/setup/world_setupper.rb', line 17

def setup_exchange(exchange, client)
  client.exchange(exchange.name, exchange.options)
  exchange.queues.each do |queue|
    client_queue = client.queue(queue.name, queue.options)
    if queue.routing_key.nil?
      client_queue.bind(exchange.name)
    else
      client_queue.bind(exchange.name, routing_key: queue.routing_key)
    end
  end
end

.setup_queue(queue, client) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/rabbitmq-spec/setup/world_setupper.rb', line 29

def setup_queue(queue, client)
  client.queue(queue.name, queue.options)
end