Module: Skein::RabbitMQ

Defined in:
lib/skein/rabbitmq.rb

Defined Under Namespace

Classes: MissingDriver

Class Method Summary collapse

Class Method Details

.connect(config = nil) ⇒ Object

REFACTOR: These should be moved to an abstract adapter



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/skein/rabbitmq.rb', line 27

def self.connect(config = nil)
  config ||= Skein.config

  self.force_require!(config)

  case (config.driver.to_s)
  when 'bunny', 'rubybunny'
    bunny = Bunny.new(config.to_h)

    bunny.start

    bunny
  when 'march_hare', 'marchhare'
    MarchHare.connect(config.to_h)
  else
    raise MissingDriver, 'Missing or invalid configuration for: driver'
  end
end

.force_require!(config = nil) ⇒ Object

Module Methods =======================================================



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/skein/rabbitmq.rb', line 9

def self.force_require!(config = nil)
  config ||= Skein.config

  case (config.driver.to_s)
  when 'bunny', 'rubybunny'
    unless (defined?(Bunny))
      require 'bunny'
    end
  when 'march_hare', 'marchhare'
    unless (defined?(MarchHare))
      require 'march_hare'
    end
  else
    raise MissingDriver, 'Missing or invalid configuration for: driver'
  end
end