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:


510
511
512
513
514
515
516
517
518
519
# File 'lib/rack/utils.rb', line 510

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)

528
529
530
# File 'lib/rack/utils.rb', line 528

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.


521
522
523
524
525
526
# File 'lib/rack/utils.rb', line 521

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