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
- #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
Instance Method Details
#[](key) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/excon/headers.rb', line 21 def [](key) if should_delegate?(key) @downcased[key.downcase] else raw_reader(key) end end |
#assoc(obj) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/excon/headers.rb', line 38 def assoc(obj) if should_delegate?(obj) @downcased.assoc(obj.downcase) else raw_assoc(obj) end end |
#delete(key, &proc) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/excon/headers.rb', line 47 def delete(key, &proc) if should_delegate?(key) @downcased.delete(key.downcase, &proc) else raw_delete(key, &proc) end end |
#fetch(key, default = nil, &proc) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/excon/headers.rb', line 55 def fetch(key, default = nil, &proc) if should_delegate?(key) if proc @downcased.fetch(key.downcase, &proc) else @downcased.fetch(key.downcase, default) end else if proc raw_fetch(key, &proc) else raw_fetch(key, default) end 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
80 81 82 83 84 85 |
# File 'lib/excon/headers.rb', line 80 def rehash raw_rehash if @downcased @downcased.rehash end end |
#values_at(*keys) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/excon/headers.rb', line 87 def values_at(*keys) raw_values_at(*keys).zip(keys).map do |v, k| if v.nil? index_case_insensitive @downcased[k.downcase] end end end |