Sha256: 00278d98c496fc27c885e4284a5d6ef0805175465aa7cf81d2e5c1cddc81c6a5

Contents?: true

Size: 800 Bytes

Versions: 8

Compression:

Stored size: 800 Bytes

Contents

require 'delegate'

module HTTParty
  class Response #:nodoc:
    class Headers < ::SimpleDelegator
      include ::Net::HTTPHeader

      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

      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
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
httparty-0.16.2 lib/httparty/response/headers.rb
httparty-0.16.1 lib/httparty/response/headers.rb
httparty-0.16.0 lib/httparty/response/headers.rb
httparty-0.15.7 lib/httparty/response/headers.rb
httparty-0.15.6 lib/httparty/response/headers.rb
httparty-0.15.5 lib/httparty/response/headers.rb
httparty-0.15.4 lib/httparty/response/headers.rb
httparty-0.15.3 lib/httparty/response/headers.rb