Sha256: a15b345d9b0cf8f120f1430ab993f8a37fccb7d851d75913fdfdd53441413e56

Contents?: true

Size: 1023 Bytes

Versions: 6

Compression:

Stored size: 1023 Bytes

Contents

module Skein::RabbitMQ
  # == Exceptions ===========================================================

  class MissingDriver < RuntimeError
  end

  # == Module Methods =======================================================

  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

  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
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
skein-0.3.7 lib/skein/rabbitmq.rb
skein-0.3.6 lib/skein/rabbitmq.rb
skein-0.3.5 lib/skein/rabbitmq.rb
skein-0.3.2 lib/skein/rabbitmq.rb
skein-0.3.1 lib/skein/rabbitmq.rb
skein-0.3.0 lib/skein/rabbitmq.rb