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.
- #raw_assoc ⇒ Object
- #raw_delete ⇒ Object
- #raw_fetch ⇒ Object
- #raw_has_key? ⇒ 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.
21 22 23 |
# File 'lib/excon/headers.rb', line 21 def initialize @downcased = {} end |
Instance Method Details
#[](key) ⇒ Object
25 26 27 |
# File 'lib/excon/headers.rb', line 25 def [](key) @downcased[key.downcase] end |
#assoc(obj) ⇒ Object
36 37 38 |
# File 'lib/excon/headers.rb', line 36 def assoc(obj) @downcased.assoc(obj.downcase) end |
#delete(key, &proc) ⇒ Object
41 42 43 44 |
# File 'lib/excon/headers.rb', line 41 def delete(key, &proc) raw_delete(key, &proc) @downcased.delete(key.downcase, &proc) end |
#fetch(key, default = nil, &proc) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/excon/headers.rb', line 46 def fetch(key, default = nil, &proc) if proc @downcased.fetch(key.downcase, &proc) else @downcased.fetch(key.downcase, default) end end |
#raw_assoc ⇒ Object
9 |
# File 'lib/excon/headers.rb', line 9 alias_method :raw_assoc, :assoc |
#raw_delete ⇒ Object
11 |
# File 'lib/excon/headers.rb', line 11 alias_method :raw_delete, :delete |
#raw_fetch ⇒ Object
12 |
# File 'lib/excon/headers.rb', line 12 alias_method :raw_fetch, :fetch |
#raw_has_key? ⇒ Object
13 |
# File 'lib/excon/headers.rb', line 13 alias_method :raw_has_key?, :has_key? |
#raw_reader ⇒ Object
7 |
# File 'lib/excon/headers.rb', line 7 alias_method :raw_reader, :[] |
#raw_rehash ⇒ Object
17 |
# File 'lib/excon/headers.rb', line 17 alias_method :raw_rehash, :rehash |
#raw_values_at ⇒ Object
19 |
# File 'lib/excon/headers.rb', line 19 alias_method :raw_values_at, :values_at |
#raw_writer ⇒ Object
6 |
# File 'lib/excon/headers.rb', line 6 alias_method :raw_writer, :[]= |
#rehash ⇒ Object
60 61 62 63 |
# File 'lib/excon/headers.rb', line 60 def rehash raw_rehash @downcased.rehash end |
#values_at(*keys) ⇒ Object
65 66 67 |
# File 'lib/excon/headers.rb', line 65 def values_at(*keys) @downcased.values_at(*keys.map {|key| key.downcase}) end |