Module: HotBunnies::Channel

Defined in:
lib/hot_bunnies/channel.rb

Instance Method Summary collapse

Instance Method Details

#default_exchangeObject



15
16
17
# File 'lib/hot_bunnies/channel.rb', line 15

def default_exchange
  self.exchange("", :durable => true, :auto_delete => false, :type => "direct")
end

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



9
10
11
12
13
# File 'lib/hot_bunnies/channel.rb', line 9

def exchange(name, options={})
  exchange = Exchange.new(self, name, options)
  exchange.declare!
  exchange
end

#on_return(&block) ⇒ Object



30
31
32
# File 'lib/hot_bunnies/channel.rb', line 30

def on_return(&block)
  self.set_return_listener(block)
end

#prefetch=(n) ⇒ Object



26
27
28
# File 'lib/hot_bunnies/channel.rb', line 26

def prefetch=(n)
  qos(:prefetch_count => n)
end

#qos(options = {}) ⇒ Object



19
20
21
22
23
24
# File 'lib/hot_bunnies/channel.rb', line 19

def qos(options={})
  if options.size == 1 && options[:prefetch_count]
  then basic_qos(options[:prefetch_count])
  else basic_qos(options.fetch(:prefetch_size, 0), options.fetch(:prefetch_count, 0), options.fetch(:global, false))
  end
end

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



5
6
7
# File 'lib/hot_bunnies/channel.rb', line 5

def queue(name, options={})
  Queue.new(self, name, options)
end