Module: StormMQ::AMQPClient

Defined in:
lib/stormmq/amqp.rb

Class Method Summary collapse

Class Method Details

.add_stormmq_options(options = {}) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/stormmq/amqp.rb', line 25

def self.add_stormmq_options(options={})
  {
    :vhost   => self.vhost_from_options(options),
    :host    => 'amqp.stormmq.com',
    :port    => 443,
    :ssl     => true
  }.merge(options)
end

.instance(options = {}) ⇒ Object



17
18
19
# File 'lib/stormmq/amqp.rb', line 17

def self.instance(options={})
  Bunny.new(self.add_stormmq_options(options))
end

.run(options = {}, &block) ⇒ Object



21
22
23
# File 'lib/stormmq/amqp.rb', line 21

def self.run(options={}, &block)
  Bunny.run(self.add_stormmq_options(options), &block)
end

.vhost_from_options(options) ⇒ Object



34
35
36
37
38
# File 'lib/stormmq/amqp.rb', line 34

def self.vhost_from_options(options)
  vhost = "/#{options[:company]}/#{options[:system]}/#{options[:environment]}"
  [:company, :system, :environment].each {|option| options.delete(option)}
  vhost
end