Parent

Files

Moqueue::MockExchange

Attributes

direct[R]
fanout[R]
topic[R]

Public Class Methods

new(opts={}) click to toggle source
# File lib/moqueue/mock_exchange.rb, line 8
def new(opts={})
  if opts[:topic] && topic_exchange = MockBroker.instance.find_topic_exchange(opts[:topic])
    return topic_exchange
  end
  
  if opts[:fanout] && fanout = MockBroker.instance.find_fanout_exchange(opts[:fanout])
    return fanout
  end
  
  if opts[:direct] && direct = MockBroker.instance.find_direct_exchange(opts[:direct])
    return direct
  end
  
  super
end
new(opts={}) click to toggle source
# File lib/moqueue/mock_exchange.rb, line 26
def initialize(opts={})
  if @topic = opts[:topic]
    MockBroker.instance.register_topic_exchange(self)
  elsif @fanout = opts[:fanout]
    MockBroker.instance.register_fanout_exchange(self)
  elsif @direct = opts[:direct]
    MockBroker.instance.register_direct_exchange(self)
  end
end

Public Instance Methods

acked_messages() click to toggle source
# File lib/moqueue/mock_exchange.rb, line 40
def acked_messages
  attached_queues.map do |q|
    q = q.first if q.kind_of?(Array)
    q.acked_messages
  end.flatten
end
attach_queue(queue, opts={}) click to toggle source
# File lib/moqueue/mock_exchange.rb, line 47
def attach_queue(queue, opts={})
  if topic
    attached_queues << [queue, TopicBindingKey.new(opts[:key])]
  elsif direct
    attached_queues << [queue, DirectBindingKey.new(opts[:key])]
  else
    attached_queues << queue
  end
end
attached_queues() click to toggle source
# File lib/moqueue/mock_exchange.rb, line 36
def attached_queues
  @attached_queues ||= []
end
publish(message, opts={}) click to toggle source
# File lib/moqueue/mock_exchange.rb, line 57
def publish(message, opts={})
  require_routing_key(opts) if topic
  matching_queues(opts).each do |q| 
    q.receive(message, prepare_header_opts(opts))
  end
end
received_ack_for_message?(message) click to toggle source
# File lib/moqueue/mock_exchange.rb, line 64
def received_ack_for_message?(message)
  acked_messages.include?(message)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.