module Bunny

NOTE: This file is rather a temporary hack to fix github.com/ruby-amqp/bunny/issues/9 then some permanent solution. It's mostly copied from the AMQP and AMQ Client gems. Later on we should use AMQ Client directly and just inherit from the AMQ::Client::Sync::Consumer class.

if we don't require the version file the same way as in the gemspec, the version file will be loaded twice. and we hate warnings.

Constants

Timer
VERSION

Public Class Methods

deprecation_warning(method, version, explanation) click to toggle source

Print deprecation warning.

# File lib/bunny.rb, line 29
def self.deprecation_warning(method, version, explanation)
  warn "~ #{method} will be removed in Bunny #{version}. #{explanation}"
end
new(connection_string_or_opts = Hash.new, opts = Hash.new) click to toggle source

Instantiates new Bunny::Client

# File lib/bunny.rb, line 35
def self.new(connection_string_or_opts = Hash.new, opts = Hash.new)
  # Set up Bunny according to AMQP spec version required
  if connection_string_or_opts.respond_to?(:keys) && opts.empty?
    opts = connection_string_or_opts
  end

  spec_version = opts[:spec] || '08'

  # Return client
  setup(spec_version, connection_string_or_opts, opts)
end
run(opts = {}, &block) click to toggle source

Runs a code block using a short-lived connection

# File lib/bunny.rb, line 49
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 24
def self.version
  VERSION
end