Class: RubyAPI::Session
- Inherits:
-
Object
- Object
- RubyAPI::Session
- Defined in:
- lib/fastrb/session.rb
Constant Summary collapse
- SESSION_COOKIE =
"_fastrb_session".freeze
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(request, secret_key: nil) ⇒ Session
constructor
A new instance of Session.
- #serialize ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(request, secret_key: nil) ⇒ Session
Returns a new instance of Session.
10 11 12 13 14 |
# File 'lib/fastrb/session.rb', line 10 def initialize(request, secret_key: nil) @request = request @secret_key = secret_key || "fastrb_default_secret" @data = load_session end |
Instance Method Details
#[](key) ⇒ Object
16 17 18 |
# File 'lib/fastrb/session.rb', line 16 def [](key) @data[key.to_s] end |
#[]=(key, value) ⇒ Object
20 21 22 |
# File 'lib/fastrb/session.rb', line 20 def []=(key, value) @data[key.to_s] = value end |
#serialize ⇒ Object
28 29 30 31 |
# File 'lib/fastrb/session.rb', line 28 def serialize json = JSON.generate(@data) encode(json) end |
#to_hash ⇒ Object
24 25 26 |
# File 'lib/fastrb/session.rb', line 24 def to_hash @data.dup end |