Class: Lotus::Action::CookieJar
- Inherits:
-
Object
- Object
- Lotus::Action::CookieJar
- Defined in:
- lib/lotus/action/cookie_jar.rb
Overview
A set of HTTP Cookies
It acts as an Hash
Constant Summary collapse
- HTTP_HEADER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The key that returns raw cookies from the Rack env
'HTTP_COOKIE'.freeze
- COOKIE_HASH_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The key used by Rack to set the cookies as an Hash in the env
'rack.request.cookie_hash'.freeze
- COOKIE_STRING_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The key used by Rack to set the cookies as a String in the env
'rack.request.cookie_string'.freeze
Instance Method Summary collapse
-
#[](key) ⇒ Object?
Returns the object associated with the given key.
-
#[]=(key, value) ⇒ void
Associate the given value with the given key and store them.
-
#finish ⇒ void
Finalize itself, by setting the proper headers to add and remove cookies, before the response is returned to the webserver.
-
#initialize(env, headers) ⇒ CookieJar
constructor
Initialize the CookieJar.
Constructor Details
#initialize(env, headers) ⇒ CookieJar
Initialize the CookieJar
39 40 41 42 |
# File 'lib/lotus/action/cookie_jar.rb', line 39 def initialize(env, headers) @_headers = headers = Utils::Hash.new(extract(env)).symbolize! end |
Instance Method Details
#[](key) ⇒ Object?
Returns the object associated with the given key
63 64 65 |
# File 'lib/lotus/action/cookie_jar.rb', line 63 def [](key) [key] end |
#[]=(key, value) ⇒ void
This method returns an undefined value.
Associate the given value with the given key and store them
75 76 77 |
# File 'lib/lotus/action/cookie_jar.rb', line 75 def []=(key, value) [key] = value end |
#finish ⇒ void
This method returns an undefined value.
Finalize itself, by setting the proper headers to add and remove cookies, before the response is returned to the webserver.
52 53 54 |
# File 'lib/lotus/action/cookie_jar.rb', line 52 def finish .each {|k,v| v.nil? ? (k) : (k, v) } end |