Class: ActiveRestClient::HeadersList
- Inherits:
-
Object
- Object
- ActiveRestClient::HeadersList
- Defined in:
- lib/active_rest_client/headers_list.rb
Constant Summary collapse
- STORE_MULTIPLE_VALUES =
["set-cookie"]
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #each(split_multiple_headers = false) ⇒ Object
-
#initialize ⇒ HeadersList
constructor
A new instance of HeadersList.
Constructor Details
#initialize ⇒ HeadersList
Returns a new instance of HeadersList.
4 5 6 |
# File 'lib/active_rest_client/headers_list.rb', line 4 def initialize @store = {} end |
Instance Method Details
#[](key) ⇒ Object
18 19 20 21 |
# File 'lib/active_rest_client/headers_list.rb', line 18 def [](key) key = find_existing(key) @store[key] end |
#[]=(key, value) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/active_rest_client/headers_list.rb', line 8 def []=(key,value) key = find_existing(key) if STORE_MULTIPLE_VALUES.include?(key.downcase) @store[key] ||= [] @store[key] << value else @store[key] = value end end |
#each(split_multiple_headers = false) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/active_rest_client/headers_list.rb', line 23 def each(split_multiple_headers = false) @store.keys.each do |key| value = @store[key] if value.is_a?(Array) && split_multiple_headers value.each do |inner_value| yield(key, inner_value) end else yield(key, value) end end end |