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
102 103 104 105 106 |
# File 'lib/rack/test/cookie_jar.rb', line 102 def initialize( = [], default_host = DEFAULT_HOST) @default_host = default_host @cookies = @cookies.sort! end |
Instance Method Details
#<<(new_cookie) ⇒ Object
132 133 134 135 136 137 138 139 |
# File 'lib/rack/test/cookie_jar.rb', line 132 def <<() @cookies.reject! do || .replaces?() end @cookies << @cookies.sort! end |
#[](name) ⇒ Object
108 109 110 111 112 |
# File 'lib/rack/test/cookie_jar.rb', line 108 def [](name) = hash_for(nil) # TODO: Should be case insensitive [name] && [name].value end |
#[]=(name, value) ⇒ Object
114 115 116 |
# File 'lib/rack/test/cookie_jar.rb', line 114 def []=(name, value) merge("#{name}=#{Rack::Utils.escape(value)}") end |
#for(uri) ⇒ Object
:api: private
142 143 144 |
# File 'lib/rack/test/cookie_jar.rb', line 142 def for(uri) hash_for(uri).values.map { |c| c.raw }.join(';') end |
#merge(raw_cookies, uri = nil) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/rack/test/cookie_jar.rb', line 118 def merge(, uri = nil) return unless if .is_a? String = .split("\n") .reject!{|c| c.empty? } end .each do || = Cookie.new(, uri, @default_host) self << if .valid?(uri) end end |
#to_hash ⇒ Object
146 147 148 149 150 151 152 153 154 |
# File 'lib/rack/test/cookie_jar.rb', line 146 def to_hash = {} hash_for(nil).each do |name, | [name] = .value end return end |