1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[general] Allow default wait_for interval to be overiden globally.

This commit is contained in:
radekg 2013-12-13 07:03:10 +01:00
parent a8f7033530
commit c9daa2ba1c
3 changed files with 13 additions and 1 deletions

View file

@ -20,6 +20,7 @@ require 'fog/core/current_machine'
require 'fog/core/deprecation' require 'fog/core/deprecation'
require 'fog/core/errors' require 'fog/core/errors'
require 'fog/core/hmac' require 'fog/core/hmac'
require 'fog/core/interval'
require 'fog/core/logger' require 'fog/core/logger'
require 'fog/core/model' require 'fog/core/model'
require 'fog/core/mock' require 'fog/core/mock'

11
lib/fog/core/interval.rb Normal file
View file

@ -0,0 +1,11 @@
module Fog
@interval = 1
def self.interval
@interval
end
def self.interval=(interval)
raise ArgumentError, "interval must be non-negative" unless interval >= 0
@interval = interval
end
end

View file

@ -1,5 +1,5 @@
module Fog module Fog
def self.wait_for(timeout=Fog.timeout, interval=1, &block) def self.wait_for(timeout=Fog.timeout, interval=Fog.interval, &block)
duration = 0 duration = 0
start = Time.now start = Time.now
until yield || duration > timeout until yield || duration > timeout