module Bunny

Constants

VERSION

Public Class Methods

new(opts = {}) click to toggle source

Instantiates new Bunny::Client

# File 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) click to toggle source

Runs a code block using a short-lived connection

# File 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
version() click to toggle source

Returns the Bunny version number

# File lib/bunny.rb, line 23
def self.version
        VERSION
end