Class: Faraday::Request::Authorization
- Inherits:
 - 
      Middleware
      
        
- Object
 - Middleware
 - Faraday::Request::Authorization
 
 
- Defined in:
 - lib/puppet/feature/faraday/request/authorization.rb
 
Constant Summary collapse
- KEY =
 "Authorization".freeze
Class Method Summary collapse
- 
  
    
      .build_hash(type, hash)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Internal.
 - 
  
    
      .header(type, token)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public.
 
Instance Method Summary collapse
- 
  
    
      #call(env)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public.
 - 
  
    
      #initialize(app, type, token)  ⇒ Authorization 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Authorization.
 
Methods inherited from Middleware
dependency, inherited, loaded?, new
Methods included from MiddlewareRegistry
#fetch_middleware, #load_middleware, #lookup_middleware, #middleware_mutex, #register_middleware
Constructor Details
#initialize(app, type, token) ⇒ Authorization
Returns a new instance of Authorization.
      28 29 30 31  | 
    
      # File 'lib/puppet/feature/faraday/request/authorization.rb', line 28 def initialize(app, type, token) @header_value = self.class.header(type, token) super(app) end  | 
  
Class Method Details
.build_hash(type, hash) ⇒ Object
Internal
      18 19 20 21 22 23 24 25 26  | 
    
      # File 'lib/puppet/feature/faraday/request/authorization.rb', line 18 def self.build_hash(type, hash) offset = KEY.size + type.size + 3 comma = ",\n#{' ' * offset}" values = [] hash.each do |key, value| values << "#{key}=#{value.to_s.inspect}" end "#{type} #{values * comma}" end  | 
  
.header(type, token) ⇒ Object
Public
      6 7 8 9 10 11 12 13 14 15  | 
    
      # File 'lib/puppet/feature/faraday/request/authorization.rb', line 6 def self.header(type, token) case token when String, Symbol "#{type} #{token}" when Hash build_hash(type.to_s, token) else raise ArgumentError, "Can't build an Authorization #{type} header from #{token.inspect}" end end  |