Class: BigSession::SessionId
- Inherits:
-
Object
- Object
- BigSession::SessionId
- Defined in:
- lib/big_session/session_id.rb
Overview
SessionId object bridges an access from users to session id
Class Method Summary collapse
- .current ⇒ Object
-
.new_session_id ⇒ Object
def set(value = nil) Thread.current = value || new_session_id end.
- .with_session_id(session_id, &_block) ⇒ Object
Class Method Details
.current ⇒ Object
16 17 18 |
# File 'lib/big_session/session_id.rb', line 16 def current container.last end |
.new_session_id ⇒ Object
def set(value = nil)
Thread.current[::BigSession::THREAD_BIG_SESSION_ID_KEY] =
value || new_session_id
end
27 28 29 |
# File 'lib/big_session/session_id.rb', line 27 def new_session_id SecureRandom.hex(16) end |
.with_session_id(session_id, &_block) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/big_session/session_id.rb', line 9 def with_session_id(session_id, &_block) container.push(session_id) yield ensure container.pop end |