Class: Rack::Test::CookieJar
- Inherits:
-
Object
- Object
- Rack::Test::CookieJar
- Defined in:
- lib/rack/test/cookie_jar.rb
Overview
:nodoc:
Instance Method Summary collapse
- #<<(new_cookie) ⇒ Object
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
-
#for(uri) ⇒ Object
:api: private.
-
#initialize(cookies = [], default_host = DEFAULT_HOST) ⇒ CookieJar
constructor
:api: private.
- #merge(raw_cookies, uri = nil) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(cookies = [], default_host = DEFAULT_HOST) ⇒ CookieJar
:api: private
101 102 103 104 105 |
# File 'lib/rack/test/cookie_jar.rb', line 101 def initialize( = [], default_host = DEFAULT_HOST) @default_host = default_host @cookies = @cookies.sort! end |
Instance Method Details
#<<(new_cookie) ⇒ Object
127 128 129 130 131 132 133 134 |
# File 'lib/rack/test/cookie_jar.rb', line 127 def <<() @cookies.reject! do || .replaces?() end @cookies << @cookies.sort! end |
#[](name) ⇒ Object
107 108 109 110 111 |
# File 'lib/rack/test/cookie_jar.rb', line 107 def [](name) = hash_for(nil) # TODO: Should be case insensitive [name] && [name].value end |
#[]=(name, value) ⇒ Object
113 114 115 |
# File 'lib/rack/test/cookie_jar.rb', line 113 def []=(name, value) merge("#{name}=#{Rack::Utils.escape(value)}") end |
#for(uri) ⇒ Object
:api: private
137 138 139 |
# File 'lib/rack/test/cookie_jar.rb', line 137 def for(uri) hash_for(uri).values.map { |c| c.raw }.join(';') end |
#merge(raw_cookies, uri = nil) ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'lib/rack/test/cookie_jar.rb', line 117 def merge(, uri = nil) return unless = .split("\n") if .is_a? String .each do || = Cookie.new(, uri, @default_host) self << if .valid?(uri) end end |
#to_hash ⇒ Object
141 142 143 144 145 146 147 148 149 |
# File 'lib/rack/test/cookie_jar.rb', line 141 def to_hash = {} hash_for(nil).each do |name, | [name] = .value end return end |