module Desk::Configuration
Defines constants and methods related to configuration
Constants
- DEFAULT_ADAPTER
The adapter that will be used to connect if none is set
@note The default faraday adapter is Net::HTTP.
- DEFAULT_AUTH_METHOD
By default, OAUTH is selected
- DEFAULT_BASIC_AUTH_PASSWORD
By default, don't set a password
- DEFAULT_BASIC_AUTH_USERNAME
By default, don't set a username
- DEFAULT_CONSUMER_KEY
By default, don't set an application key
- DEFAULT_CONSUMER_SECRET
By default, don't set an application secret
- DEFAULT_DOMAIN
By default, use the desk.com hosted domain
- DEFAULT_FORMAT
The response format appended to the path and sent in the 'Accept' header if none is set
@note JSON is preferred over XML because it is more concise and faster to parse.
- DEFAULT_LOGGER
The logger that will be used to log all HTTP requests
@note By default, don't set any logger
- DEFAULT_MAX_REQUESTS
By default, set the max requests to 60 per minute
- DEFAULT_OAUTH_TOKEN
By default, don't set a user oauth token
- DEFAULT_OAUTH_TOKEN_SECRET
By default, don't set a user oauth secret
- DEFAULT_PROXY
By default, don't use a proxy server
- DEFAULT_SUBDOMAIN
By default use example
- DEFAULT_SUPPORT_EMAIL
By default, don't set a support email address
- DEFAULT_TIMEOUT
By default, don't set a default timeout
- DEFAULT_USER_AGENT
The user agent that will be sent to the
API
endpoint if none is set- DEFAULT_USE_MAX_REQUESTS
By default, don't use the max request feature
- DEFAULT_VERSION
The user agent that will be sent to the
API
endpoint if none is set- VALID_FORMATS
An array of valid request/response formats
@note Not all methods support the XML format.
- VALID_OPTIONS_KEYS
An array of valid keys in the options hash when configuring a {Twitter::API}
Attributes
Public Class Methods
When this module is extended, set all configuration options to their default values
# File lib/desk/configuration.rb, line 104 def self.extended(base) base.reset end
Public Instance Methods
# File lib/desk/configuration.rb, line 118 def adapter Thread.current[:adapter] ||= DEFAULT_ADAPTER end
# File lib/desk/configuration.rb, line 122 def adapter=(val) Thread.current[:adapter] = val end
# File lib/desk/configuration.rb, line 126 def auth_method Thread.current[:auth_method] ||= DEFAULT_ADAPTER end
# File lib/desk/configuration.rb, line 130 def auth_method=(val) Thread.current[:auth_method] = val end
Convenience method to allow configuration options to be set in a block
# File lib/desk/configuration.rb, line 109 def configure yield self end
# File lib/desk/configuration.rb, line 134 def consumer_key Thread.current[:consumer_key] ||= DEFAULT_CONSUMER_KEY end
# File lib/desk/configuration.rb, line 138 def consumer_key=(val) Thread.current[:consumer_key] = val end
# File lib/desk/configuration.rb, line 142 def consumer_secret Thread.current[:consumer_secret] ||= DEFAULT_CONSUMER_SECRET end
# File lib/desk/configuration.rb, line 146 def consumer_secret=(val) Thread.current[:consumer_secret] = val end
# File lib/desk/configuration.rb, line 150 def domain Thread.current[:domain] ||= DEFAULT_DOMAIN end
# File lib/desk/configuration.rb, line 154 def domain=(val) Thread.current[:domain] = val end
# File lib/desk/configuration.rb, line 158 def format Thread.current[:format] ||= DEFAULT_FORMAT end
# File lib/desk/configuration.rb, line 162 def format=(val) Thread.current[:format] = val end
# File lib/desk/configuration.rb, line 166 def logger Thread.current[:logger] ||= DEFAULT_LOGGER end
# File lib/desk/configuration.rb, line 170 def logger=(val) Thread.current[:logger] = val end
# File lib/desk/configuration.rb, line 174 def max_requests Thread.current[:max_requests] ||= DEFAULT_MAX_REQUESTS end
# File lib/desk/configuration.rb, line 178 def max_requests=(val) Thread.current[:max_requests] = val end
# File lib/desk/configuration.rb, line 182 def oauth_token Thread.current[:oauth_token] ||= DEFAULT_OAUTH_TOKEN end
# File lib/desk/configuration.rb, line 186 def oauth_token=(val) Thread.current[:oauth_token] = val end
# File lib/desk/configuration.rb, line 190 def oauth_token_secret Thread.current[:oauth_token_secret] ||= DEFAULT_OAUTH_TOKEN_SECRET end
# File lib/desk/configuration.rb, line 194 def oauth_token_secret=(val) Thread.current[:oauth_token_secret] = val end
Create a hash of options and their values
# File lib/desk/configuration.rb, line 114 def options Hash[VALID_OPTIONS_KEYS.map {|key| [key, send(key)] }] end
# File lib/desk/configuration.rb, line 198 def proxy Thread.current[:proxy] ||= DEFAULT_PROXY end
# File lib/desk/configuration.rb, line 202 def proxy=(val) Thread.current[:proxy] = val end
Reset all configuration options to defaults
# File lib/desk/configuration.rb, line 255 def reset self.adapter = DEFAULT_ADAPTER self.auth_method = DEFAULT_AUTH_METHOD self.basic_auth_username= DEFAULT_BASIC_AUTH_USERNAME self.basic_auth_password= DEFAULT_BASIC_AUTH_PASSWORD self.consumer_key = DEFAULT_CONSUMER_KEY self.consumer_secret = DEFAULT_CONSUMER_SECRET self.domain = DEFAULT_DOMAIN self.format = DEFAULT_FORMAT self.logger = DEFAULT_LOGGER self.max_requests = DEFAULT_MAX_REQUESTS self.oauth_token = DEFAULT_OAUTH_TOKEN self.oauth_token_secret = DEFAULT_OAUTH_TOKEN_SECRET self.proxy = DEFAULT_PROXY self.subdomain = DEFAULT_SUBDOMAIN self.support_email = DEFAULT_SUPPORT_EMAIL self.use_max_requests = DEFAULT_USE_MAX_REQUESTS self.user_agent = DEFAULT_USER_AGENT self.version = DEFAULT_VERSION self.timeout = DEFAULT_TIMEOUT self end
# File lib/desk/configuration.rb, line 206 def subdomain Thread.current[:subdomain] ||= DEFAULT_SUBDOMAIN end
# File lib/desk/configuration.rb, line 210 def subdomain=(val) Thread.current[:subdomain] = val end
# File lib/desk/configuration.rb, line 214 def support_email Thread.current[:support_email] ||= DEFAULT_SUPPORT_EMAIL end
# File lib/desk/configuration.rb, line 218 def support_email=(val) Thread.current[:support_email] = val end
# File lib/desk/configuration.rb, line 246 def timeout Thread.current[:timeout] ||= DEFAULT_TIMEOUT end
# File lib/desk/configuration.rb, line 250 def timeout=(val) Thread.current[:timeout] = val end
# File lib/desk/configuration.rb, line 222 def use_max_requests Thread.current[:use_max_requests] ||= DEFAULT_USE_MAX_REQUESTS end
# File lib/desk/configuration.rb, line 226 def use_max_requests=(val) Thread.current[:use_max_requests] = val end
# File lib/desk/configuration.rb, line 230 def user_agent Thread.current[:user_agent] ||= DEFAULT_USER_AGENT end
# File lib/desk/configuration.rb, line 234 def user_agent=(val) Thread.current[:user_agent] = val end
# File lib/desk/configuration.rb, line 238 def version Thread.current[:version] ||= DEFAULT_VERSION end
# File lib/desk/configuration.rb, line 242 def version=(val) Thread.current[:version] = val end