Module: EdgeCast::Config

Included in:
EdgeCast
Defined in:
lib/edge_cast/config.rb

Overview

Defines constants and methods related to configuration

Constant Summary collapse

DEFAULT_ADAPTER =

The HTTP connection adapter that will be used to connect if none is set

:net_http
DEFAULT_CONNECTION_OPTIONS =

The Faraday connection options if none is set

{}
DEFAULT_HOST =
'api.edgecast.com'
DEFAULT_API_TOKEN =

The oauth token if none is set

nil
DEFAULT_USER_AGENT =

The value sent in the ‘User-Agent’ header if none is set

"EdgeCast Ruby Gem #{EdgeCast::VERSION}"
VALID_OPTIONS_KEYS =

An array of valid keys in the options hash when configuring a EdgeCast::Client

[
  :adapter,
  :connection_options,
  :account_number,
  :api_token,
  :user_agent
]

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



33
34
35
# File 'lib/edge_cast/config.rb', line 33

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:



38
39
40
41
# File 'lib/edge_cast/config.rb', line 38

def configure
  yield self
  self
end

#optionsObject

Create a hash of options and their values



44
45
46
# File 'lib/edge_cast/config.rb', line 44

def options
  VALID_OPTIONS_KEYS.inject({}) { |opts, k| opts[k] = send(k); opts }
end

#resetObject

Reset all configuration options to defaults



49
50
51
52
53
54
55
# File 'lib/edge_cast/config.rb', line 49

def reset
  self.adapter            = DEFAULT_ADAPTER
  self.connection_options = DEFAULT_CONNECTION_OPTIONS
  self.api_token          = DEFAULT_API_TOKEN
  self.user_agent         = DEFAULT_USER_AGENT
  self
end