2019-04-24 06:50:00 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
class NamespacedSessionStore
|
|
|
|
delegate :[], :[]=, to: :store
|
|
|
|
|
2019-07-05 02:12:29 -04:00
|
|
|
def initialize(key, session = Session.current)
|
2019-04-24 06:50:00 -04:00
|
|
|
@key = key
|
2019-07-05 02:12:29 -04:00
|
|
|
@session = session
|
2019-04-24 06:50:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def initiated?
|
2019-07-05 02:12:29 -04:00
|
|
|
!session.nil?
|
2019-04-24 06:50:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def store
|
2019-07-05 02:12:29 -04:00
|
|
|
return unless session
|
2019-04-24 06:50:00 -04:00
|
|
|
|
2019-07-05 02:12:29 -04:00
|
|
|
session[@key] ||= {}
|
|
|
|
session[@key]
|
2019-04-24 06:50:00 -04:00
|
|
|
end
|
2019-07-05 02:12:29 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :session
|
2019-04-24 06:50:00 -04:00
|
|
|
end
|
|
|
|
end
|