Class: Merb::Test::CookieJar
- Inherits:
-
Object
- Object
- Merb::Test::CookieJar
- Defined in:
- merb-core/lib/merb-core/test/helpers/cookie_jar.rb
Instance Method Summary (collapse)
- - (Object) for(jar, uri) private
-
- (CookieJar) initialize
constructor
private
A new instance of CookieJar.
- - (Object) update(jar, uri, raw_cookies) private
Constructor Details
- (CookieJar) initialize
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
A new instance of CookieJar
78 79 80 |
# File 'merb-core/lib/merb-core/test/helpers/cookie_jar.rb', line 78 def initialize @jars = {} end |
Instance Method Details
- (Object) for(jar, uri)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'merb-core/lib/merb-core/test/helpers/cookie_jar.rb', line 105 def for(jar, uri) = {} @jars[jar] ||= [] # The cookies are sorted by most specific first. So, we loop through # all the cookies in order and add it to a hash by cookie name if # the cookie can be sent to the current URI. It's added to the hash # so that when we are done, the cookies will be unique by name and # we'll have grabbed the most specific to the URI. @jars[jar].each do || [.name] = .raw if .matches?(uri) end .values.join(';') end |
- (Object) update(jar, uri, raw_cookies)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'merb-core/lib/merb-core/test/helpers/cookie_jar.rb', line 83 def update(jar, uri, ) return unless # Initialize all the the received cookies = [] .each_line do |raw| c = Cookie.new(raw, uri.host) << c if c.valid?(uri) end @jars[jar] ||= [] # Remove all the cookies that will be updated @jars[jar].delete_if do |existing| .find { |c| [c.name, c.domain, c.path] == [existing.name, existing.domain, existing.path] } end @jars[jar].concat @jars[jar].sort! end |