Class: Bunnicula::Rabbit

Inherits:
Object show all
Extended by:
DslBase
Defined in:
lib/bunnicula/rabbit.rb

Direct Known Subclasses

VampireRabbit

Instance Method Summary collapse

Methods included from DslBase

dsl_attr

Constructor Details

#initialize(constr = nil) ⇒ Rabbit

Returns a new instance of Rabbit.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bunnicula/rabbit.rb', line 13

def initialize(constr=nil)
  return unless constr
  if (constr =~ /amqp:\/\//)
    uri = URI.parse(constr)
    host uri.host
    port uri.port || 5672
    username uri.user || "guest"
    password uri.password || "guest"
    vhost uri.path.strip.length < 1 ? "/" : uri.path
  else
    host(constr)
  end
end

Instance Method Details

#to_h ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/bunnicula/rabbit.rb', line 27

def to_h
  {
          :host=>host,
          :port=>port,
          :username=>username,
          :password=>password,
          :vhost=>vhost
  }
end