Module: Lifecycle::Configuration

Included in:
Lifecycle
Defined in:
lib/lifecycle_api/configuration.rb

Constant Summary collapse

VALID_CONNECTION_KEYS =
[:endpoint, :user_agent, :method].freeze
VALID_OPTIONS_KEYS =
[:api_key, :format].freeze
VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
DEFAULT_ENDPOINT =

DEFAULT_ENDPOINT = ‘api-test.lifecycle.io/v1

'http://localhost:3400'
DEFAULT_METHOD =
:post
DEFAULT_USER_AGENT =
"Lifecycle API Ruby Gem #{Lifecycle::VERSION}".freeze
DEFAULT_API_KEY =
nil
DEFAULT_FORMAT =
:json

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Make sure we have the default values set when we get ‘extended’



20
21
22
# File 'lib/lifecycle_api/configuration.rb', line 20

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



32
33
34
# File 'lib/lifecycle_api/configuration.rb', line 32

def configure
  yield self
end

#optionsObject

implement a method that returns all the configuration values inside the Lifecycle module this seems unessasary TODO: refactor/remove this method



37
38
39
# File 'lib/lifecycle_api/configuration.rb', line 37

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

#resetObject



24
25
26
27
28
29
30
31
# File 'lib/lifecycle_api/configuration.rb', line 24

def reset
  self.endpoint   = DEFAULT_ENDPOINT
  self.method     = DEFAULT_METHOD
  self.user_agent = DEFAULT_USER_AGENT

  self.api_key    = DEFAULT_API_KEY
  self.format     = DEFAULT_FORMAT
end