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 189
189:       def initialize(hash={})
190:         @names = {}
191:         hash.each { |k, v| self[k] = v }
192:       end

Public Instance methods

[Source]

     # File lib/rack/utils.rb, line 205
205:       def [](k)
206:         super @names[k.downcase]
207:       end

[Source]

     # File lib/rack/utils.rb, line 209
209:       def []=(k, v)
210:         delete k
211:         @names[k.downcase] = k
212:         super k, v
213:       end

[Source]

     # File lib/rack/utils.rb, line 215
215:       def delete(k)
216:         super @names.delete(k.downcase)
217:       end
has_key?(k)

Alias for include?

[Source]

     # File lib/rack/utils.rb, line 219
219:       def include?(k)
220:         @names.has_key? k.downcase
221:       end
key?(k)

Alias for include?

member?(k)

Alias for include?

[Source]

     # File lib/rack/utils.rb, line 232
232:       def merge(other)
233:         hash = dup
234:         hash.merge! other
235:       end

[Source]

     # File lib/rack/utils.rb, line 227
227:       def merge!(other)
228:         other.each { |k, v| self[k] = v }
229:         self
230:       end

[Source]

     # File lib/rack/utils.rb, line 194
194:       def to_hash
195:         inject({}) do |hash, (k,v)|
196:           if v.respond_to? :to_ary
197:             hash[k] = v.to_ary.join("\n")
198:           else
199:             hash[k] = v
200:           end
201:           hash
202:         end
203:       end

[Validate]