Module: Pipedriver::Configuration

Included in:
Pipedriver
Defined in:
lib/pipedriver/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 =
'https://api.pipedrive.com/v1'
DEFAULT_METHOD =
:get
DEFAULT_USER_AGENT =
"Pipedriver API Ruby Gem #{Pipedriver::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’



19
20
21
# File 'lib/pipedriver/configuration.rb', line 19

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
end

#optionsObject

Return the configuration values set in this module



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

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

#resetObject



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

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