Class: Capybara::Driver::Webkit::CookieJar

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/driver/webkit/cookie_jar.rb

Overview

A simple cookie jar implementation. Does not take special cookie attributes into account like expire, max-age, httponly, secure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(browser) ⇒ CookieJar

Returns a new instance of CookieJar.



9
10
11
# File 'lib/capybara/driver/webkit/cookie_jar.rb', line 9

def initialize(browser)
  @browser = browser
end

Instance Attribute Details

#browserObject (readonly)

Returns the value of attribute browser.



7
8
9
# File 'lib/capybara/driver/webkit/cookie_jar.rb', line 7

def browser
  @browser
end

Instance Method Details

#[](*args) ⇒ Object



13
14
15
16
# File 'lib/capybara/driver/webkit/cookie_jar.rb', line 13

def [](*args)
  cookie = find(*args)
  cookie && cookie.value
end

#find(name, domain = nil, path = "/") ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/capybara/driver/webkit/cookie_jar.rb', line 18

def find(name, domain = nil, path = "/")
  # we are sorting by path size because more specific paths take
  # precendence
  cookies.sort_by { |c| -c.path.size }.find { |c|
    c.name.downcase == name.downcase &&
    (!domain || valid_domain?(c, domain)) &&
    (!path   || valid_path?(c, path))
  }
end