Class: Bezel::Session
- Inherits:
-
Object
- Object
- Bezel::Session
- Defined in:
- lib/session.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
-
#initialize(req) ⇒ Session
constructor
A new instance of Session.
- #store_session(res) ⇒ Object
Constructor Details
#initialize(req) ⇒ Session
Returns a new instance of Session.
5 6 7 8 9 10 11 |
# File 'lib/session.rb', line 5 def initialize(req) if req.['_'] @cookie = JSON.parse(req.['_bezel']) else @cookie = {} end end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 |
# File 'lib/session.rb', line 13 def [](key) @cookie[key] end |
#[]=(key, val) ⇒ Object
17 18 19 |
# File 'lib/session.rb', line 17 def []=(key, val) @cookie[key] = val end |
#store_session(res) ⇒ Object
21 22 23 24 |
# File 'lib/session.rb', line 21 def store_session(res) = @cookie.to_json res.('_bezel', value: , path: '/' ) end |