Class: CatchBox::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/catch_box/auth.rb

Instance Method Summary collapse

Constructor Details

#initialize(auth: proc { false }) ⇒ Auth

Returns a new instance of Auth.



7
8
9
# File 'lib/catch_box/auth.rb', line 7

def initialize(auth: proc { false })
  @auth = auth
end

Instance Method Details

#call(auth) ⇒ Object



11
12
13
# File 'lib/catch_box/auth.rb', line 11

def call(auth)
  @auth = auth
end

#map(payload, env) ⇒ Object



15
16
17
18
19
# File 'lib/catch_box/auth.rb', line 15

def map(payload, env)
  return if @auth.call(payload, env)

  raise ::CatchBox::NotAuthorized
end