Class: BunnyHair::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/bunny_hair/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection = BunnyHair.new) ⇒ Channel

Returns a new instance of Channel.



5
6
7
8
9
# File 'lib/bunny_hair/channel.rb', line 5

def initialize(connection=BunnyHair.new)
  @connection = connection
  @test_queues = []
  @test_exchanges = []
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



3
4
5
# File 'lib/bunny_hair/channel.rb', line 3

def connection
  @connection
end

#test_exchangesObject (readonly)

Returns the value of attribute test_exchanges.



3
4
5
# File 'lib/bunny_hair/channel.rb', line 3

def test_exchanges
  @test_exchanges
end

#test_queuesObject (readonly)

Returns the value of attribute test_queues.



3
4
5
# File 'lib/bunny_hair/channel.rb', line 3

def test_queues
  @test_queues
end

Instance Method Details

#ack(*args) ⇒ Object Also known as: acknowledge



33
34
# File 'lib/bunny_hair/channel.rb', line 33

def ack(*args)
end

#direct(name, options = {}) ⇒ Object



29
30
31
# File 'lib/bunny_hair/channel.rb', line 29

def direct(name, options={})
  exchange_factory(name, :direct, options)
end

#fanout(name, options = {}) ⇒ Object



25
26
27
# File 'lib/bunny_hair/channel.rb', line 25

def fanout(name, options={})
  exchange_factory(name, :fanout, options)
end

#queue(name, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/bunny_hair/channel.rb', line 11

def queue(name, options={})
  if queue = @test_queues.select {|q| q.name == name }[0]
    return queue
  end

  Queue.new(name, options).tap do |queue|
    @test_queues << queue
  end
end

#topic(name, options = {}) ⇒ Object



21
22
23
# File 'lib/bunny_hair/channel.rb', line 21

def topic(name, options={})
  exchange_factory(name, :topic, options)
end