module ESPN::Configuration

Public: All methods useful for configuration. This module should be extended in the ESPN module, so ESPN can be configured.

Examples

module ESPN
  extend Configuration
end

Constants

DEFAULT_ADAPTER

Public: The default adapter used for requests.

DEFAULT_API_VERSION

Public: The default API Version.

DEFAULT_TIMEOUT

Public: The default timeout for HTTP Requests.

DEFAULT_USER_AGENT

Public: The default user agent.

VALID_OPTIONS_KEYS

Public: Array of all configuration options for an ESPN::Client.

Attributes

adapter[RW]

Public: Gets/Sets the Symbol adapter.

api_key[RW]

Public: Gets/Sets the String api key.

api_version[RW]

Public: Gets/Sets the Fixnum api version.

open_timeout[RW]

Public: Gets/Sets the Fixnum open timeout.

proxy[RW]

Public: Gets/Sets the String proxy.

timeout[RW]

Public: Gets/Sets the Fixnum timeout.

user_agent[RW]

Public: Gets/Sets the String user agent.

Public Class Methods

extended(base) click to toggle source

Internal: Hook when this module is extended in another, we call reset.

Returns nothing.

# File lib/espn/configuration.rb, line 56
def self.extended(base)
  base.reset
end

Public Instance Methods

configure() { |self| ... } click to toggle source

Public: The ability to configure ESPN default options.

Examples

ESPN.configure do |c|
  c.api_key = 'abc123'
end

Yields ESPN::Configuration.

# File lib/espn/configuration.rb, line 69
def configure
  yield self
end
options() click to toggle source

Public: Get all valid options with their defaults.

Returns a Hash.

# File lib/espn/configuration.rb, line 76
def options
  VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) }
end
reset() click to toggle source

Public: Reset all valid options to their defaults.

Returns nothing.

# File lib/espn/configuration.rb, line 83
def reset
  self.adapter        = DEFAULT_ADAPTER
  self.api_version    = DEFAULT_API_VERSION
  self.user_agent     = DEFAULT_USER_AGENT
  self.timeout        = DEFAULT_TIMEOUT
  self.open_timeout   = DEFAULT_TIMEOUT
  self.api_key        = nil
  self.proxy          = nil
end