Class: Bunnicula::VampireRabbit
- Defined in:
- lib/bunnicula/vampire_rabbit.rb
Instance Attribute Summary collapse
-
#relays ⇒ Object
readonly
Returns the value of attribute relays.
Instance Method Summary collapse
-
#initialize(host = nil) ⇒ VampireRabbit
constructor
A new instance of VampireRabbit.
- #relay(*args, &block) ⇒ Object
- #suck(amq) ⇒ Object
Methods inherited from Rabbit
Methods included from DslBase
Constructor Details
#initialize(host = nil) ⇒ VampireRabbit
Returns a new instance of VampireRabbit.
5 6 7 8 |
# File 'lib/bunnicula/vampire_rabbit.rb', line 5 def initialize(host=nil) super(host) @relays = [] end |
Instance Attribute Details
#relays ⇒ Object (readonly)
Returns the value of attribute relays.
3 4 5 |
# File 'lib/bunnicula/vampire_rabbit.rb', line 3 def relays @relays end |
Instance Method Details
#relay(*args, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bunnicula/vampire_rabbit.rb', line 10 def relay(*args,&block) = args. args = [""] if args.length == 0 && block_given? args.each do |from_exchange_name| relay = Bunnicula::Relay.new relay.from(from_exchange_name,.dup) if block_given? if (block.arity > 0) block.call(relay) else relay.instance_eval(&block) end end @relays << relay end end |
#suck(amq) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/bunnicula/vampire_rabbit.rb', line 27 def suck(amq) DaemonKit.logger.info "Setting up relays to #{host}:#{port}, vhost=#{vhost} as #{username}" @bunny = Bunnicula::BunnyFarm.breed(:host=>host, :port=>port, :vhost=>vhost, :user=>username, :pass=>password) @relays.each do |relay| relay.start(amq,@bunny) end DaemonKit.logger.info "Let the good times roll, #{host}" end |