Sha256: 5c646c5d016a4eacd0e1f602bff9d1ab2931ee6c9aacfa9f9a7f983cef5bb022

Contents?: true

Size: 548 Bytes

Versions: 7

Compression:

Stored size: 548 Bytes

Contents

class HTTParty::CookieHash < Hash #:nodoc:
  CLIENT_COOKIES = %w(path expires domain path secure httponly)

  def add_cookies(value)
    case value
    when Hash
      merge!(value)
    when String
      value.split('; ').each do |cookie|
        array = cookie.split('=', 2)
        self[array[0].to_sym] = array[1]
      end
    else
      raise "add_cookies only takes a Hash or a String"
    end
  end

  def to_cookie_string
    delete_if { |k, v| CLIENT_COOKIES.include?(k.to_s.downcase) }.collect { |k, v| "#{k}=#{v}" }.join("; ")
  end
end

Version data entries

7 entries across 6 versions & 3 rubygems

Version Path
simplenet-client-0.2.0 ./vendor/bundle/ruby/1.9.1/gems/httparty-0.13.7/lib/httparty/cookie_hash.rb
simplenet-client-0.2.0 ./vendor/bundle/ruby/2.0.0/gems/httparty-0.13.7/lib/httparty/cookie_hash.rb
httparty-0.13.7 lib/httparty/cookie_hash.rb
httparty-0.13.6 lib/httparty/cookie_hash.rb
httpserious-0.13.5.lstoll1 lib/httparty/cookie_hash.rb
httparty-0.13.5 lib/httparty/cookie_hash.rb
httparty-0.13.4 lib/httparty/cookie_hash.rb