lib/profitbricks/wait_for.rb in profitbricks-sdk-ruby-1.0.5 vs lib/profitbricks/wait_for.rb in profitbricks-sdk-ruby-1.1.0

- old
+ new

@@ -1,16 +1,20 @@ module ProfitBricks - def self.wait_for(timeout = ProfitBricks::Config.timeout, interval = ProfitBricks::Config.interval, &_block) + # Resource wait_for check + def self.wait_for(timeout = ProfitBricks::Config.timeout, + interval = ProfitBricks::Config.interval, + &_block) duration = 0 start = Time.now retries = 0 until yield || duration > timeout sleep(interval.respond_to?(:call) ? interval.call(retries += 1).to_f : interval.to_f) duration = Time.now - start end if duration > timeout - raise StandardError, "The specified wait_for timeout (#{timeout} seconds) was exceeded" + fail StandardError, + "The specified wait_for timeout (#{timeout} seconds) was exceeded." else - { :duration => duration } + { duration: duration } end end end