Class: Rack::Cookies::CookieJar
- Inherits:
-
Hash
- Object
- Hash
- Rack::Cookies::CookieJar
- Defined in:
- lib/rack/contrib/cookies.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(key, options) ⇒ Object
- #delete(key, options = {}) ⇒ Object
- #finish!(resp) ⇒ Object
-
#initialize(cookies) ⇒ CookieJar
constructor
A new instance of CookieJar.
Constructor Details
#initialize(cookies) ⇒ CookieJar
Returns a new instance of CookieJar.
6 7 8 9 10 11 |
# File 'lib/rack/contrib/cookies.rb', line 6 def initialize() @set_cookies = {} @delete_cookies = {} super() update() end |
Instance Method Details
#[](name) ⇒ Object
13 14 15 |
# File 'lib/rack/contrib/cookies.rb', line 13 def [](name) super(name.to_s) end |
#[]=(key, options) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/rack/contrib/cookies.rb', line 17 def []=(key, ) unless .is_a?(Hash) = { :value => } end [:path] ||= '/' @set_cookies[key] = super(key.to_s, [:value]) end |
#delete(key, options = {}) ⇒ Object
27 28 29 30 31 |
# File 'lib/rack/contrib/cookies.rb', line 27 def delete(key, = {}) [:path] ||= '/' @delete_cookies[key] = super(key.to_s) end |
#finish!(resp) ⇒ Object
33 34 35 36 |
# File 'lib/rack/contrib/cookies.rb', line 33 def finish!(resp) @set_cookies.each { |k, v| resp.(k, v) } @delete_cookies.each { |k, v| resp.(k, v) } end |