5faa98f481
- This can be accessed with Session.current and is restored after. - Data can be stored under a key with NamespacedSessionStore
27 lines
444 B
Ruby
27 lines
444 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
class Session
|
|
STORE_KEY = :session_storage
|
|
|
|
class << self
|
|
def with_session(session)
|
|
old = self.current
|
|
self.current = session
|
|
yield
|
|
ensure
|
|
self.current = old
|
|
end
|
|
|
|
def current
|
|
Thread.current[STORE_KEY]
|
|
end
|
|
|
|
protected
|
|
|
|
def current=(value)
|
|
Thread.current[STORE_KEY] = value
|
|
end
|
|
end
|
|
end
|
|
end
|