Module: Merb::SessionMixin
- Defined in:
- lib/merb-core/dispatch/session.rb
Overview
This is mixed into Merb::Controller on framework boot.
Defined Under Namespace
Modules: RequestMixin Classes: NoSessionContainer, SessionOverflow
Class Method Summary collapse
-
.included(base) ⇒ Object
:api: private.
-
.needs_new_cookie! ⇒ Object
Marks this session as needing a new cookie.
-
.needs_new_cookie? ⇒ Boolean
Does session need new cookie?.
-
.rand_uuid ⇒ Object
Returns String:: A random 32 character string for use as a unique session ID.
Instance Method Summary collapse
-
#session(session_store = nil) ⇒ Object
Parameters session_store<String>:: The type of session store to access.
Class Method Details
.included(base) ⇒ Object
:api: private
59 60 61 62 63 |
# File 'lib/merb-core/dispatch/session.rb', line 59 def self.included(base) # Register a callback to finalize sessions - needs to run before the cookie # callback extracts Set-Cookie headers from request.cookies. base._after_dispatch_callbacks.unshift lambda { |c| c.request.finalize_session } end |
.needs_new_cookie! ⇒ Object
Marks this session as needing a new cookie.
:api: private
102 103 104 |
# File 'lib/merb-core/dispatch/session.rb', line 102 def @_new_cookie = true end |
.needs_new_cookie? ⇒ Boolean
Does session need new cookie?
Returns
- Boolean
-
true if a new cookie is needed, false otherwise.
:api: private
112 113 114 |
# File 'lib/merb-core/dispatch/session.rb', line 112 def @_new_cookie end |
.rand_uuid ⇒ Object
Returns
- String
-
A random 32 character string for use as a unique session ID.
:api: private
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/merb-core/dispatch/session.rb', line 82 def rand_uuid if defined?(SecureRandom) SecureRandom.hex(16) else values = [ rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x1000000), rand(0x1000000), ] "%04x%04x%04x%04x%04x%06x%06x" % values end end |
Instance Method Details
#session(session_store = nil) ⇒ Object
Parameters
- session_store<String>
-
The type of session store to access.
Returns
- SessionContainer
-
The session that was extracted from the request object.
:api: public
72 73 74 |
# File 'lib/merb-core/dispatch/session.rb', line 72 def session(session_store = nil) request.session(session_store) end |