Class: Rack::Utils::HeaderHash Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A wrapper around Headers header when set.

Class Method Summary collapse

Class Method Details

.[](headers) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

:nodoc:



525
526
527
528
529
530
531
532
533
534
# File 'lib/rack/utils.rb', line 525

def self.[](headers)
  warn "Rack::Utils::HeaderHash is deprecated and will be removed in Rack 3.1, switch to Rack::Headers", uplevel: 1
  if headers.is_a?(Headers) && !headers.frozen?
    return headers
  end

  new_headers = Headers.new
  headers.each{|k,v| new_headers[k] = v}
  new_headers
end

.allocateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (TypeError)


543
544
545
# File 'lib/rack/utils.rb', line 543

def self.allocate
  raise TypeError, "cannot allocate HeaderHash"
end

.new(hash = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



536
537
538
539
540
541
# File 'lib/rack/utils.rb', line 536

def self.new(hash = {})
  warn "Rack::Utils::HeaderHash is deprecated and will be removed in Rack 3.1, switch to Rack::Headers", uplevel: 1
  headers = Headers.new
  hash.each{|k,v| headers[k] = v}
  headers
end