Class: Upkeep::Runtime::ObservedWarden
- Inherits:
-
Object
- Object
- Upkeep::Runtime::ObservedWarden
- Defined in:
- lib/upkeep/runtime.rb
Instance Method Summary collapse
- #authenticate(*args, **options) ⇒ Object
- #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.
659 660 661 |
# File 'lib/upkeep/runtime.rb', line 659 def initialize(users_by_scope) @users_by_scope = users_by_scope || {} end |
Instance Method Details
#authenticate(*args, **options) ⇒ Object
671 672 673 |
# File 'lib/upkeep/runtime.rb', line 671 def authenticate(*args, **) user(extract_scope(args, )) end |
#authenticate!(*args, **options) ⇒ Object
675 676 677 678 |
# File 'lib/upkeep/runtime.rb', line 675 def authenticate!(*args, **) scope = extract_scope(args, ) user(scope) || throw(:warden, scope: scope) end |
#authenticated?(*args, **options) ⇒ Boolean
680 681 682 |
# File 'lib/upkeep/runtime.rb', line 680 def authenticated?(*args, **) !user(extract_scope(args, )).nil? end |
#user(scope = :user, **options) ⇒ Object
663 664 665 666 667 668 669 |
# File 'lib/upkeep/runtime.rb', line 663 def user(scope = :user, **) scope = scope.fetch(:scope, :user) if scope.is_a?(Hash) 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 |