# frozen_string_literal: true require 'securerandom' module BigSession # SessionId object bridges an access from users to session id class SessionId class << self def with_session_id(session_id, &_block) container.push(session_id) yield ensure container.pop end def current container.last end =begin def set(value = nil) Thread.current[::BigSession::THREAD_BIG_SESSION_ID_KEY] = value || new_session_id end =end def new_session_id SecureRandom.hex(16) end def container Thread.current[::BigSession::THREAD_BIG_SESSION_CONTAINER_KEY] ||= [] end end private_class_method :container end end