Class: HttpEventLogger::Event::Headers

Inherits:
Object
  • Object
show all
Defined in:
lib/http_event_logger/event/headers.rb

Instance Method Summary collapse

Constructor Details

#initialize(headers) ⇒ Headers

Returns a new instance of Headers.


6
7
8
# File 'lib/http_event_logger/event/headers.rb', line 6

def initialize(headers)
  @headers = headers.is_a?(Hash) ? headers : to_hash_if_possible(headers)
end

Instance Method Details

#[](name) ⇒ Object


10
11
12
# File 'lib/http_event_logger/event/headers.rb', line 10

def [](name)
  @headers.is_a?(Hash) ? header_value_for(name) : nil
end

#to_sObject


14
15
16
# File 'lib/http_event_logger/event/headers.rb', line 14

def to_s
  @headers.is_a?(Hash) ? @headers.map { |key, value| "#{key}: #{value}" }.join(", ") : @headers
end