Parent

Methods

Class Index [+]

Quicksearch

Merb::Test::CookieJar

Public Class Methods

new() click to toggle source

:api: private

    # File lib/merb-core/test/helpers/cookie_jar.rb, line 78
78:       def initialize
79:         @jars = {}
80:       end

Public Instance Methods

for(jar, uri) click to toggle source

:api: private

     # File lib/merb-core/test/helpers/cookie_jar.rb, line 105
105:       def for(jar, uri)
106:         cookies = {}
107:         
108:         @jars[jar] ||= []
109:         # The cookies are sorted by most specific first. So, we loop through
110:         # all the cookies in order and add it to a hash by cookie name if
111:         # the cookie can be sent to the current URI. It's added to the hash
112:         # so that when we are done, the cookies will be unique by name and
113:         # we'll have grabbed the most specific to the URI.
114:         @jars[jar].each do |cookie|
115:           cookies[cookie.name] = cookie.raw if cookie.matches?(uri)
116:         end
117:         
118:         cookies.values.join(';')
119:       end
update(jar, uri, raw_cookies) click to toggle source

:api: private

     # File lib/merb-core/test/helpers/cookie_jar.rb, line 83
 83:       def update(jar, uri, raw_cookies)
 84:         return unless raw_cookies
 85:         # Initialize all the the received cookies
 86:         cookies = []
 87:         raw_cookies.each do |raw|
 88:           c = Cookie.new(raw, uri.host)
 89:           cookies << c if c.valid?(uri)
 90:         end
 91:         
 92:         @jars[jar] ||= []
 93:         
 94:         # Remove all the cookies that will be updated
 95:         @jars[jar].delete_if do |existing|
 96:           cookies.find { |c| [c.name, c.domain, c.path] == [existing.name, existing.domain, existing.path] }
 97:         end
 98:         
 99:         @jars[jar].concat cookies
100:         
101:         @jars[jar].sort!
102:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.