From c9daa2ba1c5980df548b0c0d7d9b87595a529919 Mon Sep 17 00:00:00 2001 From: radekg Date: Fri, 13 Dec 2013 07:03:10 +0100 Subject: [PATCH] [general] Allow default wait_for interval to be overiden globally. --- lib/fog/core.rb | 1 + lib/fog/core/interval.rb | 11 +++++++++++ lib/fog/core/wait_for.rb | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 lib/fog/core/interval.rb diff --git a/lib/fog/core.rb b/lib/fog/core.rb index 38d618ad6..c70de8ffd 100644 --- a/lib/fog/core.rb +++ b/lib/fog/core.rb @@ -20,6 +20,7 @@ require 'fog/core/current_machine' require 'fog/core/deprecation' require 'fog/core/errors' require 'fog/core/hmac' +require 'fog/core/interval' require 'fog/core/logger' require 'fog/core/model' require 'fog/core/mock' diff --git a/lib/fog/core/interval.rb b/lib/fog/core/interval.rb new file mode 100644 index 000000000..bc670f520 --- /dev/null +++ b/lib/fog/core/interval.rb @@ -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 diff --git a/lib/fog/core/wait_for.rb b/lib/fog/core/wait_for.rb index b8ff64fa6..b621f4bb1 100644 --- a/lib/fog/core/wait_for.rb +++ b/lib/fog/core/wait_for.rb @@ -1,5 +1,5 @@ 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 start = Time.now until yield || duration > timeout