Parent

Class Index [+]

Quicksearch

Rack::Utils::HeaderHash

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

Public Class Methods

new(hash={}) click to toggle source
     # File lib/rack/utils.rb, line 293
293:       def self.new(hash={})
294:         HeaderHash === hash ? hash : super(hash)
295:       end
new(hash={}) click to toggle source
     # File lib/rack/utils.rb, line 297
297:       def initialize(hash={})
298:         super()
299:         @names = {}
300:         hash.each { |k, v| self[k] = v }
301:       end

Public Instance Methods

[](k) click to toggle source
     # File lib/rack/utils.rb, line 320
320:       def [](k)
321:         super(@names[k]) if @names[k]
322:         super(@names[k.downcase])
323:       end
[]=(k, v) click to toggle source
     # File lib/rack/utils.rb, line 325
325:       def []=(k, v)
326:         delete k
327:         @names[k] = @names[k.downcase] = k
328:         super k, v
329:       end
delete(k) click to toggle source
     # File lib/rack/utils.rb, line 331
331:       def delete(k)
332:         canonical = k.downcase
333:         result = super @names.delete(canonical)
334:         @names.delete_if { |name,| name.downcase == canonical }
335:         result
336:       end
each() click to toggle source
     # File lib/rack/utils.rb, line 303
303:       def each
304:         super do |k, v|
305:           yield(k, v.respond_to?(:to_ary) ? v.to_ary.join("\n") : v)
306:         end
307:       end
has_key?(k) click to toggle source
Alias for: include?
include?(k) click to toggle source
     # File lib/rack/utils.rb, line 338
338:       def include?(k)
339:         @names.include?(k) || @names.include?(k.downcase)
340:       end
Also aliased as: has_key?, member?, key?
key?(k) click to toggle source
Alias for: include?
member?(k) click to toggle source
Alias for: include?
merge(other) click to toggle source
     # File lib/rack/utils.rb, line 351
351:       def merge(other)
352:         hash = dup
353:         hash.merge! other
354:       end
merge!(other) click to toggle source
     # File lib/rack/utils.rb, line 346
346:       def merge!(other)
347:         other.each { |k, v| self[k] = v }
348:         self
349:       end
replace(other) click to toggle source
     # File lib/rack/utils.rb, line 356
356:       def replace(other)
357:         clear
358:         other.each { |k, v| self[k] = v }
359:         self
360:       end
to_hash() click to toggle source
     # File lib/rack/utils.rb, line 309
309:       def to_hash
310:         inject({}) do |hash, (k,v)|
311:           if v.respond_to? :to_ary
312:             hash[k] = v.to_ary.join("\n")
313:           else
314:             hash[k] = v
315:           end
316:           hash
317:         end
318:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.