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.
4 5 6 7 8 9 |
# File 'lib/rack/contrib/cookies.rb', line 4 def initialize() @set_cookies = {} @delete_cookies = {} super() update() end |
Instance Method Details
#[](name) ⇒ Object
11 12 13 |
# File 'lib/rack/contrib/cookies.rb', line 11 def [](name) super(name.to_s) end |
#[]=(key, options) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/rack/contrib/cookies.rb', line 15 def []=(key, ) unless .is_a?(Hash) = { :value => } end [:path] ||= '/' @set_cookies[key] = super(key.to_s, [:value]) end |
#delete(key, options = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/rack/contrib/cookies.rb', line 25 def delete(key, = {}) [:path] ||= '/' @delete_cookies[key] = super(key.to_s) end |
#finish!(resp) ⇒ Object
31 32 33 34 |
# File 'lib/rack/contrib/cookies.rb', line 31 def finish!(resp) @set_cookies.each { |k, v| resp.(k, v) } @delete_cookies.each { |k, v| resp.(k, v) } end |