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 368
368:       def self.new(hash={})
369:         HeaderHash === hash ? hash : super(hash)
370:       end
new(hash={}) click to toggle source
     # File lib/rack/utils.rb, line 372
372:       def initialize(hash={})
373:         super()
374:         @names = {}
375:         hash.each { |k, v| self[k] = v }
376:       end

Public Instance Methods

[](k) click to toggle source
     # File lib/rack/utils.rb, line 390
390:       def [](k)
391:         super(k) || super(@names[k.downcase])
392:       end
[]=(k, v) click to toggle source
     # File lib/rack/utils.rb, line 394
394:       def []=(k, v)
395:         canonical = k.downcase
396:         delete k if @names[canonical] && @names[canonical] != k # .delete is expensive, don't invoke it unless necessary
397:         @names[k] = @names[canonical] = k
398:         super k, v
399:       end
delete(k) click to toggle source
     # File lib/rack/utils.rb, line 401
401:       def delete(k)
402:         canonical = k.downcase
403:         result = super @names.delete(canonical)
404:         @names.delete_if { |name,| name.downcase == canonical }
405:         result
406:       end
each() click to toggle source
     # File lib/rack/utils.rb, line 378
378:       def each
379:         super do |k, v|
380:           yield(k, v.respond_to?(:to_ary) ? v.to_ary.join("\n") : v)
381:         end
382:       end
has_key?(k) click to toggle source
Alias for: include?
include?(k) click to toggle source
     # File lib/rack/utils.rb, line 408
408:       def include?(k)
409:         @names.include?(k) || @names.include?(k.downcase)
410:       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 421
421:       def merge(other)
422:         hash = dup
423:         hash.merge! other
424:       end
merge!(other) click to toggle source
     # File lib/rack/utils.rb, line 416
416:       def merge!(other)
417:         other.each { |k, v| self[k] = v }
418:         self
419:       end
replace(other) click to toggle source
     # File lib/rack/utils.rb, line 426
426:       def replace(other)
427:         clear
428:         other.each { |k, v| self[k] = v }
429:         self
430:       end
to_hash() click to toggle source
     # File lib/rack/utils.rb, line 384
384:       def to_hash
385:         hash = {}
386:         each { |k,v| hash[k] = v }
387:         hash
388:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.