Method: Fog.wait_for

Defined in:
lib/fog/core/wait_for.rb

.wait_for(timeout = Fog.timeout, interval = Fog.interval, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/fog/core/wait_for.rb', line 2

def self.wait_for(timeout=Fog.timeout, interval=Fog.interval, &block)
  duration = 0
  start = Time.now
  until yield || duration > timeout
    sleep(interval.to_f)
    duration = Time.now - start
  end
  if duration > timeout
    raise Errors::TimeoutError.new("The specified wait_for timeout (#{timeout} seconds) was exceeded")
  else
    { :duration => duration }
  end
end