Class: Rack::Request::AuthHandlers

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

Constant Summary collapse

TOKENS =
[:basic, :bearer, :mac].freeze
NIL_BLOCK =
lambda { |*_| nil }.freeze

Class Method Summary collapse

Class Method Details

.[](type) ⇒ Object



25
26
27
28
# File 'lib/rack/auth.rb', line 25

def self.[] type
  return NIL_BLOCK unless TOKENS.include? type
  blocks[type] || NIL_BLOCK
end

.blocksObject



14
15
16
17
18
# File 'lib/rack/auth.rb', line 14

def self.blocks
  @@blocks ||= nil
  @@blocks = {} if @@blocks.nil?
  @@blocks
end

.delete!(type) ⇒ Object



34
35
36
# File 'lib/rack/auth.rb', line 34

def self.delete! type
  blocks.delete type
end

.method_missing(meth, *args, &block) ⇒ Object



20
21
22
23
# File 'lib/rack/auth.rb', line 20

def self.method_missing meth, *args, &block
  super unless TOKENS.include? meth
  blocks[meth] = block
end

.reset!Object



30
31
32
# File 'lib/rack/auth.rb', line 30

def self.reset!
  blocks.clear
end