Module: G5AuthenticationClient::Configuration
- Includes:
- Configlet
- Included in:
- G5AuthenticationClient
- Defined in:
- lib/g5_authentication_client/configuration.rb
Instance Attribute Summary collapse
-
#logger ⇒ Logger
The logger to use for debug messages (defaults to STDOUT).
Class Method Summary collapse
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ G5AuthenticationClient
Configures this module through the given
block
. -
#debug? ⇒ true, false
True if debug logging is enabled; false otherwie.
-
#options ⇒ Hash<Symbol,Object>
Create a hash of configuration options and their values.
-
#reset ⇒ Object
Resets this module’s configuration.
Instance Attribute Details
#logger ⇒ Logger
Returns the logger to use for debug messages (defaults to STDOUT).
86 87 88 |
# File 'lib/g5_authentication_client/configuration.rb', line 86 def logger @logger ||= Logger.new(STDOUT) end |
Class Method Details
.extended(base) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/g5_authentication_client/configuration.rb', line 20 def self.extended(base) # Default configuration - happens whether or not .configure is called base.config :g5_auth do default debug: 'false' default username: nil default password: nil default endpoint: DEFAULT_ENDPOINT default client_id: DEFAULT_CLIENT_ID default client_secret: DEFAULT_CLIENT_SECRET default redirect_uri: DEFAULT_REDIRECT_URI default authorization_code: nil default access_token: nil default allow_password_credentials: DEFAULT_ALLOW_PASSWORD_CREDENTIALS end end |
Instance Method Details
#configure {|_self| ... } ⇒ G5AuthenticationClient
Configures this module through the given block
. Default configuration options will be applied unless they are explicitly overridden in the block
.
109 110 111 112 113 114 115 |
# File 'lib/g5_authentication_client/configuration.rb', line 109 def configure config :g5_auth do yield self end self end |
#debug? ⇒ true, false
Returns true if debug logging is enabled; false otherwie.
78 79 80 |
# File 'lib/g5_authentication_client/configuration.rb', line 78 def debug? self[:debug] == 'true' end |
#options ⇒ Hash<Symbol,Object>
Create a hash of configuration options and their values.
121 122 123 124 125 |
# File 'lib/g5_authentication_client/configuration.rb', line 121 def VALID_CONFIG_OPTIONS.inject({}) do |option, key| option.merge!(key => send(key)) end end |
#reset ⇒ Object
Resets this module’s configuration. Configuration options will be set to default values if they exist; otherwise, they will be set to nil.
133 134 135 136 |
# File 'lib/g5_authentication_client/configuration.rb', line 133 def reset VALID_CONFIG_OPTIONS.each { |opt| self.send("#{opt}=", nil) } self end |