Class: Faraday::Env
- Extended by:
 - Forwardable
 
- Defined in:
 - lib/puppet/feature/faraday/options.rb
 
Constant Summary collapse
- ContentLength =
 'Content-Length'.freeze
- StatusesWithoutBody =
 Set.new [204, 304]
- SuccessfulStatuses =
 200..299
- MethodsWithBodies =
          
A Set of HTTP verbs that typically send a body. If no body is set for these requests, the Content-Length header is set to 0.
 Set.new [:post, :put, :patch, :options]
Class Method Summary collapse
- 
  
    
      .member_set  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Internal.
 
Instance Method Summary collapse
- 
  
    
      #[](key)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public.
 - 
  
    
      #[]=(key, value)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public.
 - 
  
    
      #clear_body  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public.
 - 
  
    
      #custom_members  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Internal.
 - #in_member_set?(key) ⇒ Boolean
 - #inspect ⇒ Object
 - 
  
    
      #needs_body?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Public.
 - 
  
    
      #parallel?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Public.
 - 
  
    
      #parse_body?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Public.
 - 
  
    
      #success?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Public.
 
Class Method Details
.member_set ⇒ Object
Internal
      346 347 348  | 
    
      # File 'lib/puppet/feature/faraday/options.rb', line 346 def self.member_set @member_set ||= Set.new(members) end  | 
  
Instance Method Details
#[](key) ⇒ Object
Public
      273 274 275 276 277 278 279  | 
    
      # File 'lib/puppet/feature/faraday/options.rb', line 273 def [](key) if in_member_set?(key) super(key) else custom_members[key] end end  | 
  
#[]=(key, value) ⇒ Object
Public
      282 283 284 285 286 287 288  | 
    
      # File 'lib/puppet/feature/faraday/options.rb', line 282 def []=(key, value) if in_member_set?(key) super(key, value) else custom_members[key] = value end end  | 
  
#clear_body ⇒ Object
Public
      301 302 303 304  | 
    
      # File 'lib/puppet/feature/faraday/options.rb', line 301 def clear_body request_headers[ContentLength] = '0' self.body = '' end  | 
  
#custom_members ⇒ Object
Internal
      330 331 332  | 
    
      # File 'lib/puppet/feature/faraday/options.rb', line 330 def custom_members @custom_members ||= {} end  | 
  
#in_member_set?(key) ⇒ Boolean
      336 337 338  | 
    
      # File 'lib/puppet/feature/faraday/options.rb', line 336 def in_member_set?(key) self.class.member_set.include?(key.to_sym) end  | 
  
#inspect ⇒ Object
      316 317 318 319 320 321 322 323 324 325 326 327  | 
    
      # File 'lib/puppet/feature/faraday/options.rb', line 316 def inspect attrs = [nil] members.each do |mem| if value = send(mem) attrs << "@#{mem}=#{value.inspect}" end end if !custom_members.empty? attrs << "@custom=#{custom_members.inspect}" end %(#<#{self.class}#{attrs.join(" ")}>) end  | 
  
#needs_body? ⇒ Boolean
Public
      296 297 298  | 
    
      # File 'lib/puppet/feature/faraday/options.rb', line 296 def needs_body? !body && MethodsWithBodies.include?(method) end  | 
  
#parallel? ⇒ Boolean
Public
      312 313 314  | 
    
      # File 'lib/puppet/feature/faraday/options.rb', line 312 def parallel? !!parallel_manager end  | 
  
#parse_body? ⇒ Boolean
Public
      307 308 309  | 
    
      # File 'lib/puppet/feature/faraday/options.rb', line 307 def parse_body? !StatusesWithoutBody.include?(status) end  | 
  
#success? ⇒ Boolean
Public
      291 292 293  | 
    
      # File 'lib/puppet/feature/faraday/options.rb', line 291 def success? SuccessfulStatuses.include?(status) end  |