Module: Bunny

Defined in:
lib/ext/bunny-0.6.0/lib/bunny.rb,
lib/ext/bunny-0.6.0/lib/bunny/queue08.rb,
lib/ext/bunny-0.6.0/lib/bunny/queue09.rb,
lib/ext/bunny-0.6.0/lib/bunny/client08.rb,
lib/ext/bunny-0.6.0/lib/bunny/client09.rb,
lib/ext/bunny-0.6.0/lib/bunny/channel08.rb,
lib/ext/bunny-0.6.0/lib/bunny/channel09.rb,
lib/ext/bunny-0.6.0/lib/bunny/exchange08.rb,
lib/ext/bunny-0.6.0/lib/bunny/exchange09.rb,
lib/ext/bunny-0.6.0/lib/bunny/subscription08.rb,
lib/ext/bunny-0.6.0/lib/bunny/subscription09.rb

Defined Under Namespace

Classes: AcknowledgementError, Channel, Channel09, Client, Client09, ConnectionError, Exchange, Exchange09, ForcedChannelCloseError, ForcedConnectionCloseError, MessageError, ProtocolError, Queue, Queue09, ServerDownError, Subscription, Subscription09, UnsubscribeError

Constant Summary collapse

VERSION =
'0.6.0'

Class Method Summary collapse

Class Method Details

.new(opts = {}) ⇒ Object

Instantiates new Bunny::Client



29
30
31
32
33
34
35
# File 'lib/ext/bunny-0.6.0/lib/bunny.rb', line 29

def self.new(opts = {})
	# Set up Bunny according to AMQP spec version required
	spec_version = opts[:spec] || '08'

	# Return client
	setup(spec_version, opts)
end

.run(opts = {}, &block) ⇒ Object

Runs a code block using a short-lived connection

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ext/bunny-0.6.0/lib/bunny.rb', line 39

def self.run(opts = {}, &block)
  raise ArgumentError, 'Bunny#run requires a block' unless block

# Set up Bunny according to AMQP spec version required
spec_version = opts[:spec] || '08'
client = setup(spec_version, opts)

  begin
    client.start
    block.call(client)
  ensure
    client.stop
  end

# Return success
:run_ok
end

.versionObject

Returns the Bunny version number



23
24
25
# File 'lib/ext/bunny-0.6.0/lib/bunny.rb', line 23

def self.version
	VERSION
end