Class: RailsApiKeys::Configuration
- Inherits:
-
Object
- Object
- RailsApiKeys::Configuration
- Defined in:
- lib/rails_api_keys/configuration.rb
Overview
Optional host overrides. Set via configure.
Defaults: token_prefix derives from the app name, and owner_active uses
Devise-style active_for_authentication? when available.
Owner models opt in with Owner.has_api_keys.
Instance Attribute Summary collapse
-
#owner_active ⇒ Object
Returns the value of attribute owner_active.
-
#token_prefix ⇒ Object
Returns the value of attribute token_prefix.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #owner_active?(owner) ⇒ Boolean
- #resolved_token_prefix ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rails_api_keys/configuration.rb', line 12 def initialize @token_prefix = nil @owner_active = ->(owner) { if owner.respond_to?(:active_for_authentication?) owner.active_for_authentication? else true end } end |
Instance Attribute Details
#owner_active ⇒ Object
Returns the value of attribute owner_active.
10 11 12 |
# File 'lib/rails_api_keys/configuration.rb', line 10 def owner_active @owner_active end |
#token_prefix ⇒ Object
Returns the value of attribute token_prefix.
10 11 12 |
# File 'lib/rails_api_keys/configuration.rb', line 10 def token_prefix @token_prefix end |
Instance Method Details
#owner_active?(owner) ⇒ Boolean
29 30 31 |
# File 'lib/rails_api_keys/configuration.rb', line 29 def owner_active?(owner) owner_active.call(owner) end |
#resolved_token_prefix ⇒ Object
23 24 25 26 27 |
# File 'lib/rails_api_keys/configuration.rb', line 23 def resolved_token_prefix return token_prefix.to_s if token_prefix.present? "#{Rails.application.class.module_parent_name.downcase}_ak_" end |