1 # An ActiveRecord class which corresponds to the database table
\r
2 # +sessions+. Functions +find_session+, +create_session+,
\r
3 # +update_session+ and +destroy+ constitute the interface to class
\r
6 class SqlSession < ActiveRecord::Base
\r
7 # this class should not be reloaded
\r
12 # retrieve session data for a given +session_id+ from the database,
\r
13 # return nil if no such session exists
\r
14 def self.find_session(session_id)
\r
15 find :first, :conditions => "session_id='#{session_id}'"
\r
18 # create a new session with given +session_id+ and +data+
\r
19 def self.create_session(session_id, data)
\r
20 new(:session_id => session_id, :data => data)
\r
23 # update session data and store it in the database
\r
24 def update_session(data)
\r
25 update_attribute('data', data)
\r