Module: HTTP::AuthorizationHeader

Defined in:
lib/http/authorization_header.rb,
lib/http/authorization_header/basic_auth.rb,
lib/http/authorization_header/bearer_token.rb

Overview

Authorization header value builders

Defined Under Namespace

Classes: BasicAuth, BearerToken

Class Method Summary collapse

Class Method Details

.build(type, opts) ⇒ String

Builds Authorization header value with associated builder.

Parameters:

  • type (#to_sym)
  • opts (Object)

Returns:

  • (String)


17
18
19
20
21
22
23
# File 'lib/http/authorization_header.rb', line 17

def build(type, opts)
  klass = builders[type.to_sym]

  fail Error, "Unknown authorization type #{type}" unless klass

  klass.new opts
end

.register(type, klass) ⇒ void

This method returns an undefined value.

Associate type with given builder.

Parameters:

  • type (#to_sym)
  • klass (Class)


9
10
11
# File 'lib/http/authorization_header.rb', line 9

def register(type, klass)
  builders[type.to_sym] = klass
end