Class: FlowChat::Session::RailsSessionStore

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_chat/session/rails_session_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ RailsSessionStore

Returns a new instance of RailsSessionStore.



4
5
6
7
8
# File 'lib/flow_chat/session/rails_session_store.rb', line 4

def initialize(context)
  @session_id = context["session.id"]
  @session_store = context.controller.session
  @session_data = (session_store[session_id] || {}).with_indifferent_access
end

Instance Method Details

#delete(key) ⇒ Object



20
21
22
# File 'lib/flow_chat/session/rails_session_store.rb', line 20

def delete(key)
  set key, nil
end

#destroyObject



24
25
26
# File 'lib/flow_chat/session/rails_session_store.rb', line 24

def destroy
  session_store[session_id] = nil
end

#get(key) ⇒ Object



10
11
12
# File 'lib/flow_chat/session/rails_session_store.rb', line 10

def get(key)
  session_data[key]
end

#set(key, value) ⇒ Object



14
15
16
17
18
# File 'lib/flow_chat/session/rails_session_store.rb', line 14

def set(key, value)
  session_data[key] = value
  session_store[session_id] = session_data
  value
end