Class: AdsCommon::Auth::BaseHandler
- Inherits:
-
Object
- Object
- AdsCommon::Auth::BaseHandler
- Defined in:
- lib/ads_common/auth/base_handler.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#auth_string(credentials) ⇒ Object
Returns authorization string.
-
#get_token(credentials = nil) ⇒ Object
Returns authorization token of some kind.
-
#handle_error(error) ⇒ Object
This method handles an error according to the specifics of an authentication mechanism (to regenerate tokens, for example).
-
#initialize(config) ⇒ BaseHandler
constructor
Default initializer.
-
#property_changed(credential, value) ⇒ Object
Callback to be used by CredentialHandlers to notify the auth handler of a change in one of the credentials.
Constructor Details
#initialize(config) ⇒ BaseHandler
Default initializer.
29 30 31 32 |
# File 'lib/ads_common/auth/base_handler.rb', line 29 def initialize(config) @config = config @token = nil end |
Instance Method Details
#auth_string(credentials) ⇒ Object
Returns authorization string. Needs to be overridden.
55 56 57 |
# File 'lib/ads_common/auth/base_handler.rb', line 55 def auth_string(credentials) raise NotImplementedError, 'auth_string not overridden.' end |
#get_token(credentials = nil) ⇒ Object
Returns authorization token of some kind. Attempts to create a new one if the token has not yet been created and credentials present.
49 50 51 52 |
# File 'lib/ads_common/auth/base_handler.rb', line 49 def get_token(credentials = nil) @token = create_token(credentials) if @token.nil? and credentials return @token end |
#handle_error(error) ⇒ Object
This method handles an error according to the specifics of an authentication mechanism (to regenerate tokens, for example). The generic method simply re-raises the error.
43 44 45 |
# File 'lib/ads_common/auth/base_handler.rb', line 43 def handle_error(error) raise error end |
#property_changed(credential, value) ⇒ Object
Callback to be used by CredentialHandlers to notify the auth handler of a change in one of the credentials. Useful for e.g. invalidating a token. The generic method does nothing.
37 38 |
# File 'lib/ads_common/auth/base_handler.rb', line 37 def property_changed(credential, value) end |