Module: Colombo::Configuration

Included in:
Colombo
Defined in:
lib/colombo/configuration.rb

Constant Summary collapse

VALID_CONNECTION_KEYS =
[:endpoint, :user_agent].freeze
VALID_OPTION_KEYS =
[:api_key, :client_id].freeze
VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTION_KEYS
DEFAULT_END_POINT =
'https://api.digitalocean.com'
DEFAULT_USER_AGENT =
"Mozilla/5.0 (compatible; Colombo a Digital Ocean Ruby API Client/#{Colombo::VERSION}; +https://github/lmmendes/colombo)"
DEFAULT_API_KEY =
nil
DEFAULT_CLIENT_ID =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



38
39
40
# File 'lib/colombo/configuration.rb', line 38

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



34
35
36
# File 'lib/colombo/configuration.rb', line 34

def configure
  yield self
end

#optionsObject



29
30
31
# File 'lib/colombo/configuration.rb', line 29

def options
  Hash[ *VALID_CONFIG_KEYS.map{ |key| [key, send(key)] }.flatten ]
end

#resetObject



22
23
24
25
26
27
# File 'lib/colombo/configuration.rb', line 22

def reset
  self.endpoint   = DEFAULT_END_POINT
  self.api_key    = DEFAULT_API_KEY
  self.client_id  = DEFAULT_CLIENT_ID
  self.user_agent = DEFAULT_USER_AGENT
end