Module: WebPipe::Session
- Included in:
- Conn
- Defined in:
- lib/web_pipe/extensions/session/session.rb
Overview
See the docs for the extension linked from the README.
Constant Summary collapse
- SESSION_KEY =
Type for session keys.
Types::Strict::String
Instance Method Summary collapse
-
#add_session(key, value) ⇒ Conn
Adds given key/value pair to the session.
-
#clear_session ⇒ Conn
Deletes everything from the session.
-
#delete_session(key) ⇒ Conn
Deletes given key form the session.
-
#fetch_session(*args, &block) ⇒ Any
Fetches given key from the session.
-
#session ⇒ Rack::Session::Abstract::SessionHash
Returns Rack::Session's hash.
Instance Method Details
#add_session(key, value) ⇒ Conn
Adds given key/value pair to the session.
42 43 44 45 |
# File 'lib/web_pipe/extensions/session/session.rb', line 42 def add_session(key, value) session[SESSION_KEY[key]] = value self end |
#clear_session ⇒ Conn
Deletes everything from the session.
59 60 61 62 |
# File 'lib/web_pipe/extensions/session/session.rb', line 59 def clear_session session.clear self end |
#delete_session(key) ⇒ Conn
Deletes given key form the session.
51 52 53 54 |
# File 'lib/web_pipe/extensions/session/session.rb', line 51 def delete_session(key) session.delete(SESSION_KEY[key]) self end |
#fetch_session(*args, &block) ⇒ Any
Fetches given key from the session.
32 33 34 35 |
# File 'lib/web_pipe/extensions/session/session.rb', line 32 def fetch_session(*args, &block) SESSION_KEY[args[0]] session.fetch(*args, &block) end |
#session ⇒ Rack::Session::Abstract::SessionHash
Returns Rack::Session's hash
17 18 19 20 21 22 23 |
# File 'lib/web_pipe/extensions/session/session.rb', line 17 def session env.fetch(Rack::RACK_SESSION) do raise ConnSupport::MissingMiddlewareError.new( 'session', 'Rack::Session', 'https://www.rubydoc.info/github/rack/rack/Rack/Session' ) end end |