Module: Iodine::Http::SessionManager
- Defined in:
- lib/iodine/http/session.rb
Overview
session management for Iodine’s Http Server
Defined Under Namespace
Modules: FileSessionStorage, MemSessionStorage
Class Method Summary collapse
-
.get(id) ⇒ Object
returns a session object.
-
.storage ⇒ Object
returns the current session storage system.
-
.storage=(session_storage = nil) ⇒ Object
Sets the session storage system, to allow for different storage systems.
Class Method Details
.get(id) ⇒ Object
returns a session object
109 110 111 |
# File 'lib/iodine/http/session.rb', line 109 def get id storage.fetch(id) end |
.storage ⇒ Object
returns the current session storage system.
131 132 133 |
# File 'lib/iodine/http/session.rb', line 131 def storage @storage ||= Iodine::Http::SessionManager::FileSessionStorage end |
.storage=(session_storage = nil) ⇒ Object
Sets the session storage system, to allow for different storage systems.
A Session Storage system must answer only one methods:
- fetch(id)
-
returns a Hash like session object with all the session’s data or a fresh session object if the session object did not exist before
The Session Object should update the storage whenever data is saved to the session Object. This is important also because a websocket ‘session’ could exist simultaneously with other HTTP requests (multiple browser windows) and the data should be kept updated at all times.
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/iodine/http/session.rb', line 119 def storage= session_storage = nil case session_storage when :file, nil @storage = Iodine::Http::SessionManager::FileSessionStorage when :mem @storage = Iodine::Http::SessionManager::MemSessionStorage else @storage = session_storage end end |