Skip to content

Commit

Permalink
Add timeout to Desk::Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
kunna-ujet committed Oct 16, 2017
1 parent bf4e488 commit 9449c6a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/desk/configuration.rb
Expand Up @@ -24,6 +24,7 @@ module Configuration
:support_email,
:use_max_requests,
:user_agent,
:timeout,
:version].freeze

# An array of valid request/response formats
Expand Down Expand Up @@ -92,6 +93,9 @@ module Configuration
# By default, don't set a support email address
DEFAULT_SUPPORT_EMAIL = nil

# By default, don't set a default timeout
DEFAULT_TIMEOUT = nil

attr_reader :DEFAULT_ADAPTER
# @private
attr_accessor *VALID_OPTIONS_KEYS
Expand Down Expand Up @@ -239,6 +243,14 @@ def version=(val)
Thread.current[:version] = val
end

def timeout
Thread.current[:timeout] ||= DEFAULT_TIMEOUT
end

def timeout=(val)
Thread.current[:timeout] = val
end

# Reset all configuration options to defaults
def reset
self.adapter = DEFAULT_ADAPTER
Expand All @@ -259,6 +271,7 @@ def reset
self.use_max_requests = DEFAULT_USE_MAX_REQUESTS
self.user_agent = DEFAULT_USER_AGENT
self.version = DEFAULT_VERSION
self.timeout = DEFAULT_TIMEOUT
self
end
end
Expand Down

0 comments on commit 9449c6a

Please sign in to comment.