Class: Reactor::SessionHelper::SessionState

Inherits:
Reactor::Session::State show all
Defined in:
lib/reactor/session_helper/session_state.rb

Constant Summary collapse

USER_NAME_KEY =
"rsession$user_name".freeze
SESSION_ID_KEY =
"rsession$session_id".freeze

Instance Attribute Summary

Attributes inherited from Reactor::Session::State

#session_id, #user_name

Instance Method Summary collapse

Methods inherited from Reactor::Session::State

deserialize, #serialize

Constructor Details

#initialize(session) ⇒ SessionState

Returns a new instance of SessionState.



7
8
9
10
# File 'lib/reactor/session_helper/session_state.rb', line 7

def initialize(session)
  self.session = session
  super(session[USER_NAME_KEY], session[SESSION_ID_KEY])
end

Instance Method Details

#session_id=(new_session_id) ⇒ Object



20
21
22
23
24
# File 'lib/reactor/session_helper/session_state.rb', line 20

def session_id=(new_session_id)
  super
  # see above
  session[SESSION_ID_KEY] = new_session_id
end

#user_name=(new_user_name) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/reactor/session_helper/session_state.rb', line 12

def user_name=(new_user_name)
  super
  # this is a little bit of magic: it will trigger
  # the the session serialization routine, and will
  # persist the new information after processing the request
  session[USER_NAME_KEY] = new_user_name
end