Class: Async::Background::Web::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/async/background/web/auth.rb

Instance Method Summary collapse

Constructor Details

#initialize(callable, logger: nil) ⇒ Auth

Returns a new instance of Auth.



7
8
9
10
# File 'lib/async/background/web/auth.rb', line 7

def initialize(callable, logger: nil)
  @callable = callable
  @logger = logger
end

Instance Method Details

#authorized?(env) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
# File 'lib/async/background/web/auth.rb', line 12

def authorized?(env)
  !!@callable.call(env)
rescue StandardError => error
  @logger&.warn(
    "[async-background-web] auth callable raised: " \
    "#{error.class}: #{error.message}"
  )
  false
end