Module: Echo::Configuration

Included in:
Echo
Defined in:
lib/echor/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =

An array of valid keys in the options hash when configuring a API

[
:endpoint,
:format,
:debug,
:user,
:password,
:backplane_user,
:backplane_password,
:search_endpoint].freeze
VALID_FORMATS =
Note:

Not all methods support the XML format.

An array of valid request/response formats

[
:json,
:xml].freeze
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_ENDPOINT =
Note:

This is configurable in case you want to use HTTP instead of HTTPS, specify a different API version, or use a Echo-compatible endpoint.

The endpoint that will be used to connect if none is set

'http://api.echoenabled.com/v1'.freeze
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_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_SEARCH_ENDPOINT =
Note:

This is configurable in case you want to use HTTP instead of HTTPS or use a Echo-compatible endpoint.

The search endpoint that will be used to connect if none is set

'https://search.echo.com/'.freeze
DEFAULT_USER =

The default user for basic authoriation

nil
DEFAULT_PASSWORD =

The default password for basic authorization

nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

When this module is extended, set all configuration options to their default values



62
63
64
# File 'lib/echor/configuration.rb', line 62

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Convenience method to allow configuration options to be set in a block

Yields:

  • (_self)

Yield Parameters:



67
68
69
# File 'lib/echor/configuration.rb', line 67

def configure
  yield self
end

#optionsObject

Create a hash of options and their values



72
73
74
75
76
# File 'lib/echor/configuration.rb', line 72

def options
  options = {}
  VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) }
  options
end

#resetObject

Reset all configuration options to defaults



79
80
81
82
83
84
85
86
87
# File 'lib/echor/configuration.rb', line 79

def reset
  self.debug              = false
  self.endpoint           = DEFAULT_ENDPOINT
  self.format             = DEFAULT_FORMAT
  self.search_endpoint    = DEFAULT_SEARCH_ENDPOINT
  self.user               = DEFAULT_USER
  self.password           = DEFAULT_PASSWORD
  self
end