Class Rack::Utils::HeaderHash
In: lib/rack/utils.rb
Parent: Hash

A case-insensitive Hash that preserves the original case of a header when set.

Methods

[]   []=   delete   has_key?   include?   key?   member?   merge   merge!   new   to_hash  

Public Class methods

[Source]

     # File lib/rack/utils.rb, line 162
162:       def initialize(hash={})
163:         @names = {}
164:         hash.each { |k, v| self[k] = v }
165:       end

Public Instance methods

[Source]

     # File lib/rack/utils.rb, line 171
171:       def [](k)
172:         super @names[k.downcase]
173:       end

[Source]

     # File lib/rack/utils.rb, line 175
175:       def []=(k, v)
176:         delete k
177:         @names[k.downcase] = k
178:         super k, v
179:       end

[Source]

     # File lib/rack/utils.rb, line 181
181:       def delete(k)
182:         super @names.delete(k.downcase)
183:       end
has_key?(k)

Alias for include?

[Source]

     # File lib/rack/utils.rb, line 185
185:       def include?(k)
186:         @names.has_key? k.downcase
187:       end
key?(k)

Alias for include?

member?(k)

Alias for include?

[Source]

     # File lib/rack/utils.rb, line 198
198:       def merge(other)
199:         hash = dup
200:         hash.merge! other
201:       end

[Source]

     # File lib/rack/utils.rb, line 193
193:       def merge!(other)
194:         other.each { |k, v| self[k] = v }
195:         self
196:       end

[Source]

     # File lib/rack/utils.rb, line 167
167:       def to_hash
168:         {}.replace(self)
169:       end

[Validate]