lib/ringcentral_sdk/rest/configuration.rb in ringcentral_sdk-2.0.2 vs lib/ringcentral_sdk/rest/configuration.rb in ringcentral_sdk-2.0.3
- old
+ new
@@ -26,10 +26,11 @@
def inflate
@logger = default_logger if !defined?(@logger) || @logger.nil?
load_environment if load_env
inflate_headers
inflate_retry
+ inflate_retry_options
inflate_token
end
def default_logger
logger = Logger.new STDOUT
@@ -52,15 +53,23 @@
@retry_options = ENV['RC_RETRY_OPTIONS'] if ENV.key? 'RC_RETRY_OPTIONS'
@headers = ENV['RC_HEADERS'] if ENV.key? 'RC_HEADERS'
end
def inflate_retry
- if !defined?(@retry) || @retry.nil? || @retry.empty? || @retry.to_s.downcase == 'false'
+ if !defined?(@retry) || @retry.nil?
@retry = false
+ elsif @retry.is_a? String
+ @retry = @retry.to_s.strip.downcase == 'true' ? true : false
+ elsif ![true, false].include? @retry
+ @retry = @retry ? true : false
+ end
+ end
+
+ def inflate_retry_options
+ if @retry == false
@retry_options = {}
return
end
- @retry = true
if !@retry_options.nil? && @retry_options.to_s =~ /^\s*{/
@retry_options = MultiJson.decode @retry_options.to_s, symbolize_keys: true
else
@retry_options = {}
end