Class: HTTParty::Response::Headers

Inherits:
SimpleDelegator
  • Object
show all
Includes:
Net::HTTPHeader
Defined in:
lib/httparty/response/headers.rb

Instance Method Summary collapse

Methods included from Net::HTTPHeader

#digest_auth

Constructor Details

#initialize(header_values = nil) ⇒ Headers

Returns a new instance of Headers



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/httparty/response/headers.rb', line 8

def initialize(header_values = nil)
  @header = {}
  if header_values
    header_values.each_pair do |k,v|
      if v.is_a?(Array)
        v.each do |sub_v|
          add_field(k, sub_v)
        end
      else
        add_field(k, v)
      end
    end
  end
  super(@header)
end

Instance Method Details

#==(other) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/httparty/response/headers.rb', line 24

def ==(other)
  if other.is_a?(::Net::HTTPHeader) 
    @header == other.instance_variable_get(:@header)
  elsif other.is_a?(Hash)
    @header == other || @header == Headers.new(other).instance_variable_get(:@header)           
  end
end