Class: Upkeep::Runtime::ObservedWarden

Inherits:
Object
  • Object
show all
Defined in:
lib/upkeep/runtime.rb

Instance Method Summary collapse

Constructor Details

#initialize(users_by_scope) ⇒ ObservedWarden

Returns a new instance of ObservedWarden.



618
619
620
# File 'lib/upkeep/runtime.rb', line 618

def initialize(users_by_scope)
  @users_by_scope = users_by_scope || {}
end

Instance Method Details

#authenticate(*args, **options) ⇒ Object



629
630
631
# File 'lib/upkeep/runtime.rb', line 629

def authenticate(*args, **options)
  user(extract_scope(args, options))
end

#authenticated?(*args, **options) ⇒ Boolean

Returns:

  • (Boolean)


633
634
635
# File 'lib/upkeep/runtime.rb', line 633

def authenticated?(*args, **options)
  !user(extract_scope(args, options)).nil?
end

#user(scope = :user, **options) ⇒ Object



622
623
624
625
626
627
# File 'lib/upkeep/runtime.rb', line 622

def user(scope = :user, **options)
  scope = options.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