Module: Elmas::Config
- Included in:
- Elmas
- Defined in:
- lib/elmas/config.rb
Constant Summary collapse
- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash
[ :access_token, :adapter, :client_id, :client_secret, :connection_options, :redirect_uri, :response_format, :user_agent, :endpoint, :division, :base_url, :refresh_token ].freeze
- DEFAULT_ACCESS_TOKEN =
By default, don’t set a user access token
"".freeze
- DEFAULT_REFRESH_TOKEN =
"".freeze
- DEFAULT_ADAPTER =
Note:
The default faraday adapter is Net::HTTP.
The adapter that will be used to connect if none is set
Faraday.default_adapter
- DEFAULT_CLIENT_ID =
By default, client id should be set in .env
"".freeze
- DEFAULT_CLIENT_SECRET =
By default, client secret should be set in .env
"".freeze
- DEFAULT_CONNECTION_OPTIONS =
By default, don’t set any connection options
{}.freeze
- DEFAULT_BASE_URL =
"https://start.exactonline.nl".freeze
- DEFAULT_ENDPOINT =
The endpoint that will be used to connect if none is set
"api/v1".freeze
- DEFAULT_DIVISION =
the division code you want to connect with
"".freeze
- DEFAULT_FORMAT =
The response format appended to the path and sent in the ‘Accept’ header if none is set
:json
- DEFAULT_REDIRECT_URI =
"https://www.getpostman.com/oauth2/callback".freeze
- DEFAULT_USER_AGENT =
By default, don’t set user agent
nil
- VALID_FORMATS =
An array of valid request/response formats
[:json].freeze
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
-
#options ⇒ Object
Create a hash of options and their values.
-
#reset ⇒ Object
Reset all configuration options to defaults.
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values
64 65 66 |
# File 'lib/elmas/config.rb', line 64 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
69 70 71 |
# File 'lib/elmas/config.rb', line 69 def configure yield self end |
#options ⇒ Object
Create a hash of options and their values
74 75 76 77 78 |
# File 'lib/elmas/config.rb', line 74 def VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end |
#reset ⇒ Object
Reset all configuration options to defaults
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/elmas/config.rb', line 81 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. = 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 end |