module Elmas::Config

Constants

DEFAULT_ACCESS_TOKEN

By default, don't set a user access token

DEFAULT_ADAPTER

The adapter that will be used to connect if none is set

@note The default faraday adapter is Net::HTTP.

DEFAULT_BASE_URL
DEFAULT_CLIENT_ID

By default, client id should be set in .env

DEFAULT_CLIENT_SECRET

By default, client secret should be set in .env

DEFAULT_CONNECTION_OPTIONS

By default, don't set any connection options

DEFAULT_DIVISION

the division code you want to connect with

DEFAULT_ENDPOINT

The endpoint that will be used to connect if none is set

DEFAULT_FORMAT

The response format appended to the path and sent in the 'Accept' header if none is set

DEFAULT_LOGGER
DEFAULT_REDIRECT_URI
DEFAULT_REFRESH_TOKEN
DEFAULT_USER_AGENT

By default, don't set user agent

VALID_FORMATS

An array of valid request/response formats

VALID_OPTIONS_KEYS

An array of valid keys in the options hash

Public Class Methods

extended(base) click to toggle source

When this module is extended, set all configuration options to their default values

# File lib/elmas/config.rb, line 72
def self.extended(base)
  base.reset
end

Public Instance Methods

configure() { |self| ... } click to toggle source

Convenience method to allow configuration options to be set in a block

# File lib/elmas/config.rb, line 77
def configure
  yield self
end
options() click to toggle source

Create a hash of options and their values

# File lib/elmas/config.rb, line 82
def options
  VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end
reset() click to toggle source

Reset all configuration options to defaults

# File lib/elmas/config.rb, line 89
def reset
  self.access_token       = DEFAULT_ACCESS_TOKEN
  self.adapter            = DEFAULT_ADAPTER
  self.client_id          = DEFAULT_CLIENT_ID
  self.client_secret      = DEFAULT_CLIENT_SECRET
  self.connection_options = DEFAULT_CONNECTION_OPTIONS
  self.redirect_uri       = DEFAULT_REDIRECT_URI
  self.endpoint           = DEFAULT_ENDPOINT
  self.division           = DEFAULT_DIVISION
  self.base_url           = DEFAULT_BASE_URL
  self.response_format    = DEFAULT_FORMAT
  self.user_agent         = DEFAULT_USER_AGENT
  self.refresh_token      = DEFAULT_REFRESH_TOKEN
  self.logger             = DEFAULT_LOGGER
end