Class: Puma::Util::HeaderHash
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Hash
|
|
Instance Chain:
self,
Hash
|
|
Inherits: |
Hash
|
Defined in: | lib/puma/util.rb |
Overview
A case-insensitive Hash that preserves the original case of a header when set.
Class Attribute Summary
- .to_hash readonly mod_func
Class Method Summary
- .new(hash = {}) ⇒ HeaderHash constructor
- .[](k) mod_func
- .[]=(k, v) mod_func
- .delete(k) mod_func
- .each mod_func
-
.has_key?(k)
mod_func
Alias for #include?.
- .include?(k) ⇒ Boolean (also: .has_key?, .member?, .key?) mod_func
- .initialize(hash = {}) mod_func
-
.key?(k)
mod_func
Alias for #include?.
-
.member?(k)
mod_func
Alias for #include?.
- .merge(other) mod_func
- .merge!(other) mod_func
- .replace(other) mod_func
Constructor Details
.new(hash = {}) ⇒ HeaderHash
# File 'lib/puma/util.rb', line 86
def self.new(hash={}) HeaderHash === hash ? hash : super(hash) end
Class Attribute Details
.to_hash (readonly, mod_func)
[ GitHub ]# File 'lib/puma/util.rb', line 103
def to_hash hash = {} each { |k,v| hash[k] = v } hash end
Class Method Details
.[](k) (mod_func)
[ GitHub ]# File 'lib/puma/util.rb', line 109
def [](k) super(k) || super(@names[k.downcase]) end
.[]=(k, v) (mod_func)
[ GitHub ]# File 'lib/puma/util.rb', line 113
def []=(k, v) canonical = k.downcase delete k if @names[canonical] && @names[canonical] != k # .delete is expensive, don't invoke it unless necessary @names[k] = @names[canonical] = k super k, v end
.delete(k) (mod_func)
[ GitHub ]# File 'lib/puma/util.rb', line 120
def delete(k) canonical = k.downcase result = super @names.delete(canonical) @names.delete_if { |name,| name.downcase == canonical } result end
.each (mod_func)
[ GitHub ]# File 'lib/puma/util.rb', line 96
def each super do |k, v| yield(k, v.respond_to?(:to_ary) ? v.to_ary.join("\n") : v) end end
.has_key?(k) (mod_func)
Alias for #include?.
# File 'lib/puma/util.rb', line 131
alias_method :has_key?, :include?
.include?(k) ⇒ Boolean
(mod_func)
Also known as: .has_key?, .member?, .key?
# File 'lib/puma/util.rb', line 127
def include?(k) @names.include?(k) || @names.include?(k.downcase) end
.initialize(hash = {}) (mod_func)
[ GitHub ]# File 'lib/puma/util.rb', line 90
def initialize(hash={}) super() @names = {} hash.each { |k, v| self[k] = v } end
.key?(k) (mod_func)
Alias for #include?.
# File 'lib/puma/util.rb', line 133
alias_method :key?, :include?
.member?(k) (mod_func)
Alias for #include?.
# File 'lib/puma/util.rb', line 132
alias_method :member?, :include?
.merge(other) (mod_func)
[ GitHub ]# File 'lib/puma/util.rb', line 140
def merge(other) hash = dup hash.merge! other end
.merge!(other) (mod_func)
[ GitHub ]# File 'lib/puma/util.rb', line 135
def merge!(other) other.each { |k, v| self[k] = v } self end
.replace(other) (mod_func)
[ GitHub ]# File 'lib/puma/util.rb', line 145
def replace(other) clear other.each { |k, v| self[k] = v } self end