Class: Merb::ActiveRecordSessionStore
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Merb::ActiveRecordSessionStore
- Defined in:
- lib/merb/session/active_record_session.rb
Overview
Sessions stored in ActiveRecord model.
To use ActiveRecord based sessions add the following to config/init.rb:
Merb::Config = ‘activerecord’
Class Method Summary collapse
-
.delete_session(session_id) ⇒ Object
Parameters session_id<String>:: ID of the session to delete.
-
.retrieve_session(session_id) ⇒ Object
Parameters session_id<String>:: ID of the session to retrieve.
-
.store_session(session_id, data) ⇒ Object
Parameters session_id<String>:: ID of the session to set.
Class Method Details
.delete_session(session_id) ⇒ Object
Parameters
- session_id<String>
-
ID of the session to delete.
47 48 49 |
# File 'lib/merb/session/active_record_session.rb', line 47 def delete_session(session_id) delete_all(["#{connection.quote_column_name('session_id')} IN (?)", session_id]) end |
.retrieve_session(session_id) ⇒ Object
Parameters
- session_id<String>
-
ID of the session to retrieve.
Returns
- ContainerSession
-
The session corresponding to the ID.
28 29 30 31 32 |
# File 'lib/merb/session/active_record_session.rb', line 28 def retrieve_session(session_id) if item = find_by_session_id(session_id) item.data end end |
.store_session(session_id, data) ⇒ Object
Parameters
- session_id<String>
-
ID of the session to set.
- data<ContainerSession>
-
The session to set.
37 38 39 40 41 42 43 |
# File 'lib/merb/session/active_record_session.rb', line 37 def store_session(session_id, data) if item = find_by_session_id(session_id) item.update_attributes!(:data => data) else create(:session_id => session_id, :data => data) end end |