Module: Desk::Configuration
- Included in:
- Desk
- Defined in:
- lib/desk/configuration.rb
Overview
Defines constants and methods related to configuration
Constant Summary collapse
- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash when configuring a Twitter::API
[ :adapter, :auth_method, :basic_auth_username, :basic_auth_password, :consumer_key, :consumer_secret, :domain, :format, :logger, :max_requests, :oauth_token, :oauth_token_secret, :proxy, :subdomain, :support_email, :use_max_requests, :user_agent, :timeout, :version].freeze
- VALID_FORMATS =
Note:
Not all methods support the XML format.
An array of valid request/response formats
[ :json].freeze
- DEFAULT_ADAPTER =
Note:
The default faraday adapter is Net::HTTP.
The adapter that will be used to connect if none is set
Faraday.default_adapter
- DEFAULT_AUTH_METHOD =
By default, OAUTH is selected
Desk::Authentication::Methods::OAUTH
- DEFAULT_BASIC_AUTH_USERNAME =
By default, don't set a username
nil
- DEFAULT_BASIC_AUTH_PASSWORD =
By default, don't set a password
nil
- DEFAULT_DOMAIN =
By default, use the desk.com hosted domain
"desk.com"
- DEFAULT_CONSUMER_KEY =
By default, don't set an application key
nil
- DEFAULT_CONSUMER_SECRET =
By default, don't set an application secret
nil
- DEFAULT_FORMAT =
Note:
JSON is preferred over XML because it is more concise and faster to parse.
The response format appended to the path and sent in the 'Accept' header if none is set
:json
- DEFAULT_LOGGER =
Note:
By default, don't set any logger
The logger that will be used to log all HTTP requests
nil
- DEFAULT_MAX_REQUESTS =
By default, set the max requests to 60 per minute
60
- DEFAULT_USE_MAX_REQUESTS =
By default, don't use the max request feature
false
- DEFAULT_OAUTH_TOKEN =
By default, don't set a user oauth token
nil
- DEFAULT_OAUTH_TOKEN_SECRET =
By default, don't set a user oauth secret
nil
- DEFAULT_PROXY =
By default, don't use a proxy server
nil
- DEFAULT_SUBDOMAIN =
By default use example
"example"
- DEFAULT_USER_AGENT =
The user agent that will be sent to the API endpoint if none is set
"Desk.com Ruby Gem #{Desk::VERSION}".freeze
- DEFAULT_VERSION =
The user agent that will be sent to the API endpoint if none is set
"v2".freeze
- DEFAULT_SUPPORT_EMAIL =
By default, don't set a support email address
nil
- DEFAULT_TIMEOUT =
By default, don't set a default timeout
nil
Instance Attribute Summary collapse
-
#DEFAULT_ADAPTER ⇒ Object
readonly
Returns the value of attribute DEFAULT_ADAPTER.
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
- #adapter ⇒ Object
- #adapter=(val) ⇒ Object
- #auth_method ⇒ Object
- #auth_method=(val) ⇒ Object
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
- #consumer_key ⇒ Object
- #consumer_key=(val) ⇒ Object
- #consumer_secret ⇒ Object
- #consumer_secret=(val) ⇒ Object
- #domain ⇒ Object
- #domain=(val) ⇒ Object
- #format ⇒ Object
- #format=(val) ⇒ Object
- #logger ⇒ Object
- #logger=(val) ⇒ Object
- #max_requests ⇒ Object
- #max_requests=(val) ⇒ Object
- #oauth_token ⇒ Object
- #oauth_token=(val) ⇒ Object
- #oauth_token_secret ⇒ Object
- #oauth_token_secret=(val) ⇒ Object
-
#options ⇒ Object
Create a hash of options and their values.
- #proxy ⇒ Object
- #proxy=(val) ⇒ Object
-
#reset ⇒ Object
Reset all configuration options to defaults.
- #subdomain ⇒ Object
- #subdomain=(val) ⇒ Object
- #support_email ⇒ Object
- #support_email=(val) ⇒ Object
- #timeout ⇒ Object
- #timeout=(val) ⇒ Object
- #use_max_requests ⇒ Object
- #use_max_requests=(val) ⇒ Object
- #user_agent ⇒ Object
- #user_agent=(val) ⇒ Object
- #version ⇒ Object
- #version=(val) ⇒ Object
Instance Attribute Details
#DEFAULT_ADAPTER ⇒ Object (readonly)
Returns the value of attribute DEFAULT_ADAPTER.
99 100 101 |
# File 'lib/desk/configuration.rb', line 99 def DEFAULT_ADAPTER @DEFAULT_ADAPTER end |
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values
104 105 106 |
# File 'lib/desk/configuration.rb', line 104 def self.extended(base) base.reset end |
Instance Method Details
#adapter ⇒ Object
118 119 120 |
# File 'lib/desk/configuration.rb', line 118 def adapter Thread.current[:adapter] ||= DEFAULT_ADAPTER end |
#adapter=(val) ⇒ Object
122 123 124 |
# File 'lib/desk/configuration.rb', line 122 def adapter=(val) Thread.current[:adapter] = val end |
#auth_method ⇒ Object
126 127 128 |
# File 'lib/desk/configuration.rb', line 126 def auth_method Thread.current[:auth_method] ||= DEFAULT_ADAPTER end |
#auth_method=(val) ⇒ Object
130 131 132 |
# File 'lib/desk/configuration.rb', line 130 def auth_method=(val) Thread.current[:auth_method] = val end |
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
109 110 111 |
# File 'lib/desk/configuration.rb', line 109 def configure yield self end |
#consumer_key ⇒ Object
134 135 136 |
# File 'lib/desk/configuration.rb', line 134 def consumer_key Thread.current[:consumer_key] ||= DEFAULT_CONSUMER_KEY end |
#consumer_key=(val) ⇒ Object
138 139 140 |
# File 'lib/desk/configuration.rb', line 138 def consumer_key=(val) Thread.current[:consumer_key] = val end |
#consumer_secret ⇒ Object
142 143 144 |
# File 'lib/desk/configuration.rb', line 142 def consumer_secret Thread.current[:consumer_secret] ||= DEFAULT_CONSUMER_SECRET end |
#consumer_secret=(val) ⇒ Object
146 147 148 |
# File 'lib/desk/configuration.rb', line 146 def consumer_secret=(val) Thread.current[:consumer_secret] = val end |
#domain ⇒ Object
150 151 152 |
# File 'lib/desk/configuration.rb', line 150 def domain Thread.current[:domain] ||= DEFAULT_DOMAIN end |
#domain=(val) ⇒ Object
154 155 156 |
# File 'lib/desk/configuration.rb', line 154 def domain=(val) Thread.current[:domain] = val end |
#format ⇒ Object
158 159 160 |
# File 'lib/desk/configuration.rb', line 158 def format Thread.current[:format] ||= DEFAULT_FORMAT end |
#format=(val) ⇒ Object
162 163 164 |
# File 'lib/desk/configuration.rb', line 162 def format=(val) Thread.current[:format] = val end |
#logger ⇒ Object
166 167 168 |
# File 'lib/desk/configuration.rb', line 166 def logger Thread.current[:logger] ||= DEFAULT_LOGGER end |
#logger=(val) ⇒ Object
170 171 172 |
# File 'lib/desk/configuration.rb', line 170 def logger=(val) Thread.current[:logger] = val end |
#max_requests ⇒ Object
174 175 176 |
# File 'lib/desk/configuration.rb', line 174 def max_requests Thread.current[:max_requests] ||= DEFAULT_MAX_REQUESTS end |
#max_requests=(val) ⇒ Object
178 179 180 |
# File 'lib/desk/configuration.rb', line 178 def max_requests=(val) Thread.current[:max_requests] = val end |
#oauth_token ⇒ Object
182 183 184 |
# File 'lib/desk/configuration.rb', line 182 def oauth_token Thread.current[:oauth_token] ||= DEFAULT_OAUTH_TOKEN end |
#oauth_token=(val) ⇒ Object
186 187 188 |
# File 'lib/desk/configuration.rb', line 186 def oauth_token=(val) Thread.current[:oauth_token] = val end |
#oauth_token_secret ⇒ Object
190 191 192 |
# File 'lib/desk/configuration.rb', line 190 def oauth_token_secret Thread.current[:oauth_token_secret] ||= DEFAULT_OAUTH_TOKEN_SECRET end |
#oauth_token_secret=(val) ⇒ Object
194 195 196 |
# File 'lib/desk/configuration.rb', line 194 def oauth_token_secret=(val) Thread.current[:oauth_token_secret] = val end |
#options ⇒ Object
Create a hash of options and their values
114 115 116 |
# File 'lib/desk/configuration.rb', line 114 def Hash[VALID_OPTIONS_KEYS.map {|key| [key, send(key)] }] end |
#proxy ⇒ Object
198 199 200 |
# File 'lib/desk/configuration.rb', line 198 def proxy Thread.current[:proxy] ||= DEFAULT_PROXY end |
#proxy=(val) ⇒ Object
202 203 204 |
# File 'lib/desk/configuration.rb', line 202 def proxy=(val) Thread.current[:proxy] = val end |
#reset ⇒ Object
Reset all configuration options to defaults
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# 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 |
#subdomain ⇒ Object
206 207 208 |
# File 'lib/desk/configuration.rb', line 206 def subdomain Thread.current[:subdomain] ||= DEFAULT_SUBDOMAIN end |
#subdomain=(val) ⇒ Object
210 211 212 |
# File 'lib/desk/configuration.rb', line 210 def subdomain=(val) Thread.current[:subdomain] = val end |
#support_email ⇒ Object
214 215 216 |
# File 'lib/desk/configuration.rb', line 214 def support_email Thread.current[:support_email] ||= DEFAULT_SUPPORT_EMAIL end |
#support_email=(val) ⇒ Object
218 219 220 |
# File 'lib/desk/configuration.rb', line 218 def support_email=(val) Thread.current[:support_email] = val end |
#timeout ⇒ Object
246 247 248 |
# File 'lib/desk/configuration.rb', line 246 def timeout Thread.current[:timeout] ||= DEFAULT_TIMEOUT end |
#timeout=(val) ⇒ Object
250 251 252 |
# File 'lib/desk/configuration.rb', line 250 def timeout=(val) Thread.current[:timeout] = val end |
#use_max_requests ⇒ Object
222 223 224 |
# File 'lib/desk/configuration.rb', line 222 def use_max_requests Thread.current[:use_max_requests] ||= DEFAULT_USE_MAX_REQUESTS end |
#use_max_requests=(val) ⇒ Object
226 227 228 |
# File 'lib/desk/configuration.rb', line 226 def use_max_requests=(val) Thread.current[:use_max_requests] = val end |
#user_agent ⇒ Object
230 231 232 |
# File 'lib/desk/configuration.rb', line 230 def user_agent Thread.current[:user_agent] ||= DEFAULT_USER_AGENT end |
#user_agent=(val) ⇒ Object
234 235 236 |
# File 'lib/desk/configuration.rb', line 234 def user_agent=(val) Thread.current[:user_agent] = val end |
#version ⇒ Object
238 239 240 |
# File 'lib/desk/configuration.rb', line 238 def version Thread.current[:version] ||= DEFAULT_VERSION end |
#version=(val) ⇒ Object
242 243 244 |
# File 'lib/desk/configuration.rb', line 242 def version=(val) Thread.current[:version] = val end |