Class: Rack::Test::CookieJar
- Inherits:
-
Object
- Object
- Rack::Test::CookieJar
- Defined in:
- lib/rack/test/cookie_jar.rb
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
99 100 101 102 103 |
# File 'lib/rack/test/cookie_jar.rb', line 99 def initialize( = [], default_host = DEFAULT_HOST) @default_host = default_host @cookies = @cookies.sort! end |
Instance Method Details
#<<(new_cookie) ⇒ Object
125 126 127 128 129 130 131 132 |
# File 'lib/rack/test/cookie_jar.rb', line 125 def <<() @cookies.reject! do || .replaces?() end @cookies << @cookies.sort! end |
#[](name) ⇒ Object
105 106 107 108 109 |
# File 'lib/rack/test/cookie_jar.rb', line 105 def [](name) = hash_for(nil) # TODO: Should be case insensitive [name] && [name].value end |
#[]=(name, value) ⇒ Object
111 112 113 114 |
# File 'lib/rack/test/cookie_jar.rb', line 111 def []=(name, value) # TODO: needs proper escaping merge("#{name}=#{value}") end |
#for(uri) ⇒ Object
:api: private
135 136 137 |
# File 'lib/rack/test/cookie_jar.rb', line 135 def for(uri) hash_for(uri).values.map { |c| c.raw }.join(';') end |
#merge(raw_cookies, uri = nil) ⇒ Object
116 117 118 119 120 121 122 123 |
# File 'lib/rack/test/cookie_jar.rb', line 116 def merge(, uri = nil) return unless Array().join("\n").split("\n").each do || = Cookie.new(, uri, @default_host) self << if .valid?(uri) end end |
#to_hash ⇒ Object
139 140 141 142 143 144 145 146 147 |
# File 'lib/rack/test/cookie_jar.rb', line 139 def to_hash = {} hash_for(nil).each do |name, | [name] = .value end return end |