Class: Mumukit::Nuntius::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/mumukit/nuntius/connection.rb

Class Method Summary collapse

Class Method Details

.configObject



5
6
7
8
# File 'lib/mumukit/nuntius/connection.rb', line 5

def config
  @config ||= YAML.load(ERB.new(File.read(File.expand_path '../../../../config/rabbit.yml', __FILE__)).result).
      with_indifferent_access[ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development']
end

.start(exchange_name) ⇒ Object



10
11
12
13
14
15
# File 'lib/mumukit/nuntius/connection.rb', line 10

def start(exchange_name)
  connection = Bunny.new(host: config[:host], user: config[:user], password: config[:password])
  channel = connection.start.create_channel
  exchange = channel.fanout(exchange_name)
  [connection, channel, exchange]
end