Repository URL to install this package:
|
Version:
0.0.1 ▾
|
module Gingr
module Configuration
VALID_OPTIONS_KEYS = [
:api_key,
:adapter,
:endpoint,
:api_version,
:company_app_name,
:logging
].freeze
# TODO: You may need to change this. Not all API's take a key. Adjust as necessary.
# By default don't set the api key.
DEFAULT_API_KEY = nil
# Use the default Faraday adapter.
DEFAULT_ADAPTER = Faraday.default_adapter
# Company name is used to build the url for making api calls with Gingr in
# the form https://#{company_app_name}.gingrapp.com
# By default don't set the company name
DEFAULT_COMPANY_APP_NAME = nil
DEFAULT_LOGGING = false
attr_accessor *VALID_OPTIONS_KEYS
# Convenience method to allow configuration options to be set in a block
def configure
yield self
end
def options
VALID_OPTIONS_KEYS.inject({}) do |option, key|
option.merge!(key => send(key))
end
end
# When this module is extended, reset all settings.
def self.extended(base)
base.reset
end
# TODO: Update this method with the final configurations provided above.
# Reset all configuration settings to default values.
def reset
self.api_key = DEFAULT_API_KEY
self.adapter = DEFAULT_ADAPTER
self.logging = DEFAULT_LOGGING
self.company_app_name = DEFAULT_COMPANY_APP_NAME
end
end
end