Class: Session
- Inherits:
-
Object
- Object
- Session
- Defined in:
- lib/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.
- #method_name ⇒ Object
-
#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 11 12 13 |
# File 'lib/session.rb', line 6 def initialize(req) @req = req if req.['_rails_lite_app'] @cookie = JSON.parse(req.['_rails_lite_app']) else @cookie = {} end end |
Instance Method Details
#[](key) ⇒ Object
15 16 17 |
# File 'lib/session.rb', line 15 def [](key) @cookie[key] end |
#[]=(key, val) ⇒ Object
19 20 21 |
# File 'lib/session.rb', line 19 def []=(key, val) @cookie[key] = val end |
#method_name ⇒ Object
29 30 31 |
# File 'lib/session.rb', line 29 def method_name end |
#store_session(res) ⇒ Object
serialize the hash into json and save in a cookie add to the responses cookies
25 26 27 |
# File 'lib/session.rb', line 25 def store_session(res) res.('_rails_lite_app', { path: '/', value: @cookie.to_json}) end |