Class: FlowChat::Session::RailsSessionStore
- Inherits:
-
Object
- Object
- FlowChat::Session::RailsSessionStore
- Includes:
- Instrumentation
- Defined in:
- lib/flow_chat/session/rails_session_store.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Make context available for instrumentation enrichment.
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #destroy ⇒ Object
- #get(key) ⇒ Object
-
#initialize(context) ⇒ RailsSessionStore
constructor
A new instance of RailsSessionStore.
- #set(key, value) ⇒ Object
Methods included from Instrumentation
Constructor Details
#initialize(context) ⇒ RailsSessionStore
Returns a new instance of RailsSessionStore.
9 10 11 12 13 14 15 16 17 |
# File 'lib/flow_chat/session/rails_session_store.rb', line 9 def initialize(context) @context = context @session_id = context["session.id"] @session_store = context.controller.session @session_data = (session_store[session_id] || {}).with_indifferent_access FlowChat.logger.debug { "RailsSessionStore: Initialized Rails session store for session #{session_id}" } FlowChat.logger.debug { "RailsSessionStore: Loaded session data with #{session_data.keys.size} keys" } end |
Instance Attribute Details
#context ⇒ Object (readonly)
Make context available for instrumentation enrichment
7 8 9 |
# File 'lib/flow_chat/session/rails_session_store.rb', line 7 def context @context end |
Instance Method Details
#delete(key) ⇒ Object
48 49 50 51 |
# File 'lib/flow_chat/session/rails_session_store.rb', line 48 def delete(key) FlowChat.logger.debug { "RailsSessionStore: Deleting key '#{key}' from session #{session_id}" } set key, nil end |
#destroy ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/flow_chat/session/rails_session_store.rb', line 53 def destroy # Use instrumentation for session destruction instrument(Events::SESSION_DESTROYED, { session_id: session_id, gateway: "rails" # Rails doesn't have a specific gateway context }) session_store[session_id] = nil end |
#get(key) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/flow_chat/session/rails_session_store.rb', line 19 def get(key) value = session_data[key] # Use instrumentation for data get instrument(Events::SESSION_DATA_GET, { session_id: session_id, key: key.to_s, value: value }) value end |
#set(key, value) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/flow_chat/session/rails_session_store.rb', line 32 def set(key, value) FlowChat.logger.debug { "RailsSessionStore: Setting key '#{key}' = #{value.inspect} in session #{session_id}" } session_data[key] = value session_store[session_id] = session_data # Use instrumentation for data set instrument(Events::SESSION_DATA_SET, { session_id: session_id, key: key.to_s }) FlowChat.logger.debug { "RailsSessionStore: Session data saved to Rails session store" } value end |