Class: Waves::Session
Overview
Encapsulates the session associated with a given request. A session has an expiration and path, which must be provided in a Waves::Configuration. Sensible defaults are defined in Waves::Configurations::Default
Instance Method Summary collapse
-
#[](key) ⇒ Object
Access a given data element of the session using the given key.
-
#[]=(key, val) ⇒ Object
Set the given data element of the session using the given key and value.
-
#initialize(request) ⇒ Session
constructor
Create a new session object using the given request.
-
#to_hash ⇒ Object
Return the session data as a hash.
Constructor Details
#initialize(request) ⇒ Session
Create a new session object using the given request. This is not necessarily the same as constructing a new session. See Rack::Sesssion for more info.
11 12 13 |
# File 'lib/runtime/session.rb', line 11 def initialize( request ) @data = request.rack_request.env['rack.session'] end |
Instance Method Details
#[](key) ⇒ Object
Access a given data element of the session using the given key.
19 |
# File 'lib/runtime/session.rb', line 19 def [](key) ; @data[key] ; end |
#[]=(key, val) ⇒ Object
Set the given data element of the session using the given key and value.
21 |
# File 'lib/runtime/session.rb', line 21 def []=(key,val) ; @data[key] = val ; end |
#to_hash ⇒ Object
Return the session data as a hash
16 |
# File 'lib/runtime/session.rb', line 16 def to_hash ; @data ; end |