Class: Lapin::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/lapin/config.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.amqp_urlObject

Returns the value of attribute amqp_url.



8
9
10
# File 'lib/lapin/config.rb', line 8

def amqp_url
  @amqp_url
end

.exchangeObject

Returns the value of attribute exchange.



9
10
11
# File 'lib/lapin/config.rb', line 9

def exchange
  @exchange
end

.loggingObject

Returns the value of attribute logging.



10
11
12
# File 'lib/lapin/config.rb', line 10

def logging
  @logging
end

.routing_keyObject

Returns the value of attribute routing_key.



9
10
11
# File 'lib/lapin/config.rb', line 9

def routing_key
  @routing_key
end

.vhostObject

Returns the value of attribute vhost.



8
9
10
# File 'lib/lapin/config.rb', line 8

def vhost
  @vhost
end

Class Method Details

.amqp_configObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lapin/config.rb', line 12

def amqp_config
  uri = URI.parse(amqp_url)
  {
    :user    => uri.user,
    :pass    => uri.password,
    :host    => uri.host,
    :port    => (uri.port || 5672),
    :vhost   => @vhost || uri.path ,
    :logging => @logging || false
  }
rescue Object => e
  raise "Invalid AMQP url: #{uri.inspect} (#{e})"
end