Class: Upkeep::Runtime::ObservedWarden
- Inherits:
-
Object
- Object
- Upkeep::Runtime::ObservedWarden
- Defined in:
- lib/upkeep/runtime.rb
Instance Method Summary collapse
- #authenticate(*args, **options) ⇒ Object
- #authenticated?(*args, **options) ⇒ Boolean
-
#initialize(users_by_scope) ⇒ ObservedWarden
constructor
A new instance of ObservedWarden.
- #user(scope = :user, **options) ⇒ Object
Constructor Details
#initialize(users_by_scope) ⇒ ObservedWarden
Returns a new instance of ObservedWarden.
622 623 624 |
# File 'lib/upkeep/runtime.rb', line 622 def initialize(users_by_scope) @users_by_scope = users_by_scope || {} end |
Instance Method Details
#authenticate(*args, **options) ⇒ Object
633 634 635 |
# File 'lib/upkeep/runtime.rb', line 633 def authenticate(*args, **) user(extract_scope(args, )) end |
#authenticated?(*args, **options) ⇒ Boolean
637 638 639 |
# File 'lib/upkeep/runtime.rb', line 637 def authenticated?(*args, **) !user(extract_scope(args, )).nil? end |
#user(scope = :user, **options) ⇒ Object
626 627 628 629 630 631 |
# File 'lib/upkeep/runtime.rb', line 626 def user(scope = :user, **) scope = .fetch(:scope, scope) value = @users_by_scope[scope] || @users_by_scope[scope.to_s] || @users_by_scope[scope.to_sym] Ambient.record_warden_user(scope, value) value end |