Module: Ucb::Hcm::Configuration

Included in:
Ucb::Hcm
Defined in:
lib/ucb/hcm/configuration.rb

Constant Summary collapse

VALID_CONNECTION_KEYS =
[:endpoint, :user_agent, :method].freeze
VALID_OPTIONS_KEYS =
[:app_id, :app_key, :format].freeze
VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
DEFAULT_ENDPOINT =
'https://apis.berkeley.edu/uat/hr/v3'
DEFAULT_METHOD =
:get
DEFAULT_USER_AGENT =
"Ucb::Hcm API Ruby Gem #{Ucb::Hcm::VERSION}".freeze
DEFAULT_APP_ID =
nil
DEFAULT_APP_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’



21
22
23
# File 'lib/ucb/hcm/configuration.rb', line 21

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



39
40
41
# File 'lib/ucb/hcm/configuration.rb', line 39

def configure
  yield self
end

#optionsObject



35
36
37
# File 'lib/ucb/hcm/configuration.rb', line 35

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

#resetObject



25
26
27
28
29
30
31
32
33
# File 'lib/ucb/hcm/configuration.rb', line 25

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

  self.app_id     = DEFAULT_APP_ID
  self.app_key    = DEFAULT_APP_KEY
  self.format     = DEFAULT_FORMAT
end