Class: Gitlab::NamespacedSessionStore
- Inherits:
-
Object
- Object
- Gitlab::NamespacedSessionStore
- Includes:
- Enumerable
- Defined in:
- lib/gitlab/namespaced_session_store.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(key, session = Session.current) ⇒ NamespacedSessionStore
constructor
A new instance of NamespacedSessionStore.
- #initiated? ⇒ Boolean
Constructor Details
#initialize(key, session = Session.current) ⇒ NamespacedSessionStore
Returns a new instance of NamespacedSessionStore.
7 8 9 10 |
# File 'lib/gitlab/namespaced_session_store.rb', line 7 def initialize(key, session = Session.current) @namespace_key = key @session = session end |
Instance Method Details
#[](key) ⇒ Object
22 23 24 25 26 |
# File 'lib/gitlab/namespaced_session_store.rb', line 22 def [](key) return unless session session[@namespace_key]&.fetch(key, nil) end |
#[]=(key, value) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/gitlab/namespaced_session_store.rb', line 28 def []=(key, value) return unless session session[@namespace_key] ||= {} session[@namespace_key][key] = value end |
#each(&block) ⇒ Object
16 17 18 19 20 |
# File 'lib/gitlab/namespaced_session_store.rb', line 16 def each(&block) return unless session (session[@namespace_key] || {}).each(&block) end |
#initiated? ⇒ Boolean
12 13 14 |
# File 'lib/gitlab/namespaced_session_store.rb', line 12 def initiated? !session.nil? end |