Class: Reactor::SessionHelper::SessionState

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

Constant Summary collapse

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

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.



47
48
49
50
# File 'lib/reactor/session_helper.rb', line 47

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



61
62
63
64
65
66
# File 'lib/reactor/session_helper.rb', line 61

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

#user_name=(new_user_name) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/reactor/session_helper.rb', line 52

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
  self.session[USER_NAME_KEY] = new_user_name
  new_user_name
end