Class: MiniAuth::AuthManager
- Inherits:
-
Object
- Object
- MiniAuth::AuthManager
- Defined in:
- lib/mini_auth/auth_manager.rb
Instance Attribute Summary collapse
-
#default_guard ⇒ Object
readonly
Returns the value of attribute default_guard.
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_guard(request, guard = nil) ⇒ MiniAuth::Guard
-
#initialize(default_guard, definitions) ⇒ AuthManager
constructor
A new instance of AuthManager.
- #reset_guards! ⇒ Object
Constructor Details
#initialize(default_guard, definitions) ⇒ AuthManager
Returns a new instance of AuthManager.
9 10 11 12 13 |
# File 'lib/mini_auth/auth_manager.rb', line 9 def initialize(default_guard, definitions) @default_guard = default_guard @definitions = definitions.clone(freeze: false) @guards = {} end |
Instance Attribute Details
#default_guard ⇒ Object (readonly)
Returns the value of attribute default_guard.
7 8 9 |
# File 'lib/mini_auth/auth_manager.rb', line 7 def default_guard @default_guard end |
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
7 8 9 |
# File 'lib/mini_auth/auth_manager.rb', line 7 def definitions @definitions end |
Class Method Details
.instance ⇒ MiniAuth::AuthManager
21 22 23 24 25 26 |
# File 'lib/mini_auth/auth_manager.rb', line 21 def self.instance Semaphore.synchronize do @@instances ||= {} @@instances[Thread.current.__id__] ||= make(Rails.application.config.mini_auth) end end |
.make(config) ⇒ Object
16 17 18 |
# File 'lib/mini_auth/auth_manager.rb', line 16 def self.make(config) new(config[:default], config[:guards]) end |
.reset! ⇒ Object
28 29 30 31 32 33 |
# File 'lib/mini_auth/auth_manager.rb', line 28 def self.reset! Semaphore.synchronize do @@instances ||= {} @@instances.delete(Thread.current.__id__) end end |
Instance Method Details
#fetch_guard(request, guard = nil) ⇒ MiniAuth::Guard
42 43 44 45 |
# File 'lib/mini_auth/auth_manager.rb', line 42 def fetch_guard(request, guard = nil) guard = default_guard if guard.nil? @guards[guard] ||= init_guard(request, guard) end |
#reset_guards! ⇒ Object
35 36 37 |
# File 'lib/mini_auth/auth_manager.rb', line 35 def reset_guards! @guards = {} end |