Class: FTW::Cookies

Inherits:
Object
  • Object
show all
Defined in:
lib/ftw/cookies.rb

Overview

Based on behavior and things described in RFC6265

Defined Under Namespace

Classes: Cookie

Instance Method Summary collapse

Constructor Details

#initializeCookies

A new cookies store



76
77
78
# File 'lib/ftw/cookies.rb', line 76

def initialize
  @cookies = []
end

Instance Method Details

#add(name, value = nil, attributes = {}) ⇒ Object

Add a cookie



81
82
83
84
# File 'lib/ftw/cookies.rb', line 81

def add(name, value=nil, attributes={})
  cookie = Cookie.new(name, value, attributes)
  @cookies << cookie
end

#add_from_header(set_cookie_string) ⇒ Object

Add a cookie from a header ‘Set-Cookie’ value



87
88
89
90
# File 'lib/ftw/cookies.rb', line 87

def add_from_header(set_cookie_string)
  cookie = Cookie.parse(set_cookie_string)
  @cookies << cookie
end

#for_url(url) ⇒ Object

Get cookies for a URL



93
94
95
96
# File 'lib/ftw/cookies.rb', line 93

def for_url(url)
  # TODO(sissel): only return cookies that are valid for the url
  return @cookies
end