Module: Promiscuous::AMQP

Extended by:
Autoload
Defined in:
lib/promiscuous/amqp.rb

Defined Under Namespace

Classes: Bunny, Fake, File, HotBunnies, Null

Constant Summary collapse

LIVE_EXCHANGE =
'promiscuous'

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Autoload

autoload

Class Attribute Details

.backendObject

Returns the value of attribute backend.



8
9
10
# File 'lib/promiscuous/amqp.rb', line 8

def backend
  @backend
end

.backend_classObject

Returns the value of attribute backend_class.



9
10
11
# File 'lib/promiscuous/amqp.rb', line 9

def backend_class
  @backend_class
end

Class Method Details

.connectObject



26
27
28
29
30
# File 'lib/promiscuous/amqp.rb', line 26

def connect
  return if @backend
  @backend = backend_class.new
  @backend.connect
end

.const_missing(sym) ⇒ Object



46
47
48
# File 'lib/promiscuous/amqp.rb', line 46

def const_missing(sym)
  backend_class.const_get(sym)
end

.disconnectObject



32
33
34
35
36
37
# File 'lib/promiscuous/amqp.rb', line 32

def disconnect
  return unless @backend
  @backend.disconnect
  @backend.terminate if @backend.respond_to?(:terminate)
  @backend = nil
end

.ensure_connectedObject



20
21
22
23
24
# File 'lib/promiscuous/amqp.rb', line 20

def ensure_connected
  Promiscuous.ensure_connected

  raise lost_connection_exception unless connected?
end

.lost_connection_exception(options = {}) ⇒ Object



16
17
18
# File 'lib/promiscuous/amqp.rb', line 16

def lost_connection_exception(options={})
  Promiscuous::Error::Connection.new(Promiscuous::Config.publisher_amqp_url, options)
end

.new_connection(*args) ⇒ Object



39
40
41
42
# File 'lib/promiscuous/amqp.rb', line 39

def new_connection(*args)
  ensure_connected
  backend.new_connection(*args)
end