Class: Excon::Headers
- Inherits:
-
Hash
- Object
- Hash
- Excon::Headers
- Defined in:
- lib/excon/headers.rb
Constant Summary collapse
- SENTINEL =
{}
Instance Method Summary collapse
- #[](key) ⇒ Object
- #assoc(obj) ⇒ Object
- #delete(key, &proc) ⇒ Object
- #fetch(key, default = nil, &proc) ⇒ Object
-
#initialize ⇒ Headers
constructor
A new instance of Headers.
- #merge(other_hash) ⇒ Object
- #merge!(other_hash) ⇒ Object
- #raw_assoc ⇒ Object
- #raw_delete ⇒ Object
- #raw_fetch ⇒ Object
- #raw_has_key? ⇒ Object
- #raw_merge ⇒ Object
- #raw_merge! ⇒ Object
- #raw_reader ⇒ Object
- #raw_rehash ⇒ Object
- #raw_values_at ⇒ Object
- #raw_writer ⇒ Object
- #rehash ⇒ Object
- #values_at(*keys) ⇒ Object
Constructor Details
#initialize ⇒ Headers
Returns a new instance of Headers.
24 25 26 |
# File 'lib/excon/headers.rb', line 24 def initialize @downcased = {} end |
Instance Method Details
#[](key) ⇒ Object
28 29 30 |
# File 'lib/excon/headers.rb', line 28 def [](key) @downcased[key.to_s.downcase] end |
#assoc(obj) ⇒ Object
39 40 41 |
# File 'lib/excon/headers.rb', line 39 def assoc(obj) @downcased.assoc(obj.downcase) end |
#delete(key, &proc) ⇒ Object
44 45 46 47 |
# File 'lib/excon/headers.rb', line 44 def delete(key, &proc) raw_delete(key, &proc) @downcased.delete(key.to_s.downcase, &proc) end |
#fetch(key, default = nil, &proc) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/excon/headers.rb', line 49 def fetch(key, default = nil, &proc) if proc @downcased.fetch(key.to_s.downcase, &proc) else @downcased.fetch(key.to_s.downcase, default) end end |
#merge(other_hash) ⇒ Object
63 64 65 |
# File 'lib/excon/headers.rb', line 63 def merge(other_hash) self.dup.merge!(other_hash) end |
#merge!(other_hash) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/excon/headers.rb', line 67 def merge!(other_hash) other_hash.each do |key, value| self[key] = value end raw_merge!(other_hash) end |
#raw_assoc ⇒ Object
10 |
# File 'lib/excon/headers.rb', line 10 alias_method :raw_assoc, :assoc |
#raw_delete ⇒ Object
12 |
# File 'lib/excon/headers.rb', line 12 alias_method :raw_delete, :delete |
#raw_fetch ⇒ Object
13 |
# File 'lib/excon/headers.rb', line 13 alias_method :raw_fetch, :fetch |
#raw_has_key? ⇒ Object
14 |
# File 'lib/excon/headers.rb', line 14 alias_method :raw_has_key?, :has_key? |
#raw_merge ⇒ Object
18 |
# File 'lib/excon/headers.rb', line 18 alias_method :raw_merge, :merge |
#raw_merge! ⇒ Object
19 |
# File 'lib/excon/headers.rb', line 19 alias_method :raw_merge!, :merge! |
#raw_reader ⇒ Object
8 |
# File 'lib/excon/headers.rb', line 8 alias_method :raw_reader, :[] |
#raw_rehash ⇒ Object
20 |
# File 'lib/excon/headers.rb', line 20 alias_method :raw_rehash, :rehash |
#raw_values_at ⇒ Object
22 |
# File 'lib/excon/headers.rb', line 22 alias_method :raw_values_at, :values_at |
#raw_writer ⇒ Object
7 |
# File 'lib/excon/headers.rb', line 7 alias_method :raw_writer, :[]= |
#rehash ⇒ Object
74 75 76 77 |
# File 'lib/excon/headers.rb', line 74 def rehash @downcased.rehash raw_rehash end |
#values_at(*keys) ⇒ Object
79 80 81 |
# File 'lib/excon/headers.rb', line 79 def values_at(*keys) @downcased.values_at(*keys.map {|key| key.to_s.downcase}) end |