Class: Session
- Inherits:
-
Object
- Object
- Session
- Defined in:
- lib/app/controllers/session.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
-
#initialize(req) ⇒ Session
constructor
find the cookie for this app deserialize the cookie into a hash.
-
#store_session(res) ⇒ Object
serialize the hash into json and save in a cookie add to the responses cookies.
Constructor Details
#initialize(req) ⇒ Session
find the cookie for this app deserialize the cookie into a hash
6 7 8 9 10 |
# File 'lib/app/controllers/session.rb', line 6 def initialize(req) = req.["_rails_lite_app"] = JSON.parse() if @cookie = ? : {} end |
Instance Method Details
#[](key) ⇒ Object
12 13 14 |
# File 'lib/app/controllers/session.rb', line 12 def [](key) @cookie[key] end |
#[]=(key, val) ⇒ Object
16 17 18 |
# File 'lib/app/controllers/session.rb', line 16 def []=(key, val) @cookie[key] = val end |
#store_session(res) ⇒ Object
serialize the hash into json and save in a cookie add to the responses cookies
22 23 24 25 |
# File 'lib/app/controllers/session.rb', line 22 def store_session(res) = @cookie.to_json res.('_rails_lite_app', { path: "/", value: }) end |