Class: AMQP::Integration::Rails

Inherits:
Object
  • Object
show all
Defined in:
lib/amqp/integration/rails.rb

Class Method Summary collapse

Class Method Details

.start(options_or_uri = {}, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/amqp/integration/rails.rb', line 7

def self.start(options_or_uri = {}, &block)
  yaml     = YAML.load_file(File.join(::Rails.root, "config", "amqp.yml"))
  settings = yaml.fetch(::Rails.env, Hash.new).symbolize_keys

  arg      = if options_or_uri.is_a?(Hash)
               settings.merge(options_or_uri)[:uri]
             else
               settings[:uri] || options_or_uri
             end

  EventMachine.next_tick do
    AMQP.start(arg, &block)
  end
end