Class: CustomPost
- Inherits:
-
Net::HTTP::Post
- Object
- Net::HTTP::Post
- CustomPost
- Defined in:
- lib/case_sensitive_headers.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, val) ⇒ Object
- #capitalize(name) ⇒ Object
- #header_insensitive_match(name) ⇒ Object
- #initialize_http_header(headers) ⇒ Object
Instance Method Details
#[](name) ⇒ Object
7 8 9 10 |
# File 'lib/case_sensitive_headers.rb', line 7 def [](name) _k, val = header_insensitive_match name val end |
#[]=(name, val) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/case_sensitive_headers.rb', line 12 def []=(name, val) key, _val = header_insensitive_match name key = name if key.nil? if val @header[key] = [val] else @header.delete(key) end end |
#capitalize(name) ⇒ Object
22 23 24 |
# File 'lib/case_sensitive_headers.rb', line 22 def capitalize(name) name end |
#header_insensitive_match(name) ⇒ Object
26 27 28 |
# File 'lib/case_sensitive_headers.rb', line 26 def header_insensitive_match(name) @header.find { |key, _value| key.match Regexp.new(name.to_s, Regexp::IGNORECASE) } end |
#initialize_http_header(headers) ⇒ Object
2 3 4 5 |
# File 'lib/case_sensitive_headers.rb', line 2 def initialize_http_header(headers) @header = {} headers.each { |k, v| @header[k.to_s] = [v] } end |