Class: Reloj::Session
- Inherits:
-
Object
- Object
- Reloj::Session
- Defined in:
- lib/reloj/core/session.rb
Instance Method Summary collapse
-
#[](key) ⇒ Object
convenience methods.
- #[]=(key, val) ⇒ Object
-
#initialize(req) ⇒ Session
constructor
find the cookie for this app, deserialize into hash.
-
#store_session(res) ⇒ Object
serialize the hash into json and save in a cookie, add to responses.
Constructor Details
#initialize(req) ⇒ Session
find the cookie for this app, deserialize into hash
7 8 9 10 11 12 13 14 |
# File 'lib/reloj/core/session.rb', line 7 def initialize(req) req..each do || if .name == '_rails_lite_app' @_rails_lite_app = JSON.parse(.value) end end @_rails_lite_app ||= {} end |
Instance Method Details
#[](key) ⇒ Object
convenience methods
17 18 19 |
# File 'lib/reloj/core/session.rb', line 17 def [](key) @_rails_lite_app[key] end |
#[]=(key, val) ⇒ Object
21 22 23 |
# File 'lib/reloj/core/session.rb', line 21 def []=(key, val) @_rails_lite_app[key] = val end |
#store_session(res) ⇒ Object
serialize the hash into json and save in a cookie, add to responses
26 27 28 29 30 |
# File 'lib/reloj/core/session.rb', line 26 def store_session(res) = WEBrick::Cookie.new('_rails_lite_app', @_rails_lite_app.to_json) .path = '/' res. << end |