Module: AMQP::Hermes

Defined in:
lib/amqp-hermes.rb,
lib/amqp-hermes/message.rb,
lib/amqp-hermes/receiver.rb,
lib/amqp-hermes/transmitter.rb,
lib/amqp-hermes/connectivity.rb

Defined Under Namespace

Modules: Connectivity Classes: Message, Receiver, Transmitter

Class Method Summary collapse

Class Method Details

.wait_for(something, test, max = 50) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/amqp-hermes.rb', line 11

def self.wait_for(something, test, max=50)
  res = something.send(test)
  unless [ true, false ].include?(res)
    raise "Can only wait for true or false"
  end
  return 0 if res == true

  wait_count = 0
  while !something.send(test)
    raise "Waited long enough" if ( wait_count += 1 ) > max
    sleep 0.1
  end

  return wait_count
end