Class: HTTParty::CookieHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/httparty/cookie_hash.rb

Overview

:nodoc:

Constant Summary collapse

CLIENT_COOKIES =
%w(path expires domain path secure httponly)

Instance Method Summary collapse

Instance Method Details

#add_cookies(value) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/httparty/cookie_hash.rb', line 4

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


18
19
20
# File 'lib/httparty/cookie_hash.rb', line 18

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