Module: PriceHubble::Identity
- Extended by:
- ActiveSupport::Concern
- Included in:
- PriceHubble
- Defined in:
- lib/pricehubble/identity.rb
Overview
Handles all the identity retrival high-level logic.
rubocop:disable Style/ClassVars because we split module code
Class Method Summary collapse
-
.identity ⇒ PriceHubble::Authentication
Get the current identity we use for all requests.
-
.reset_identity! ⇒ Object
Reset the current identity.
Class Method Details
.identity ⇒ PriceHubble::Authentication
Get the current identity we use for all requests. We try to authenticate against the PriceHubble Authentication API with the configured credentials from the Gem configuration. (PriceHubble.configuration
) In case this went well, we cache the result. Otherwise we raise an AuthenticationError
.
24 25 26 27 28 29 30 31 32 |
# File 'lib/pricehubble/identity.rb', line 24 def identity # Fetch a new identity with the configured identity settings from the # Gem configuration @@identity ||= auth_by_config # Take care of an expired identity @@identity = auth_by_config if @@identity.expired? # Pass back the actual identity instance @@identity end |
.reset_identity! ⇒ Object
Reset the current identity.
12 13 14 |
# File 'lib/pricehubble/identity.rb', line 12 def reset_identity! @@identity = nil end |