From ca28243dce53f0feab9efb535b00f594e511c71c Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 15 May 2013 14:10:37 +0100 Subject: Correctly work if we have no settings file present. Previously we'd try to find the setting "foo" like so: @settings['foo'].to_i || 5 This would fail if the setting wasn't defined, because nil.to_i results in 0. But we must call to_i otherwise we'll have issues comparing strings/numbers. --- lib/custodian/settings.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'lib/custodian') diff --git a/lib/custodian/settings.rb b/lib/custodian/settings.rb index 1efabf6..f177083 100644 --- a/lib/custodian/settings.rb +++ b/lib/custodian/settings.rb @@ -95,7 +95,11 @@ module Custodian def timeout _load() unless( _loaded? ) - @settings['timeout'].to_i || 30 + if ( @settings['timeout'] ) + @settings['timeout'].to_i + else + 30 + end end @@ -107,7 +111,11 @@ module Custodian def retries _load() unless( _loaded? ) - @settings['retries' ].to_i || 5 + if ( @settings['retries'] ) + @settings['retries'].to_i + else + 5 + end end @@ -123,7 +131,11 @@ module Custodian def retry_delay _load() unless( _loaded? ) - @settings['retry_delay'].to_i || 0 + if ( @settings['retry_delay'] ) + @settings['retry_delay'].to_i + else + 0 + end end -- cgit v1.2.1