Class: Merb::CouchRestSessionStore
- Inherits:
-
CouchRest::ExtendedDocument
- Object
- CouchRest::ExtendedDocument
- Merb::CouchRestSessionStore
- Defined in:
- lib/merb/session/couchrest_session.rb
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.
:api: private
51 52 53 54 55 56 57 |
# File 'lib/merb/session/couchrest_session.rb', line 51 def delete_session(session_id) begin doc = get(session_id) doc.destroy() rescue end end |
.retrieve_session(session_id) ⇒ Object
Parameters
- session_id<String>
-
ID of the session to retrieve.
Returns
- ContainerSession
-
The session corresponding to the ID.
16 17 18 19 20 21 22 23 24 |
# File 'lib/merb/session/couchrest_session.rb', line 16 def retrieve_session(session_id) begin doc = get( session_id ) return Marshal.load(doc[:data]) rescue end end |
.store_session(session_id, data) ⇒ Object
Parameters
- session_id<String>
-
ID of the session to set.
- data<ContainerSession>
-
The session to set.
:api: private
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/merb/session/couchrest_session.rb', line 31 def store_session(session_id, data) marshaled = Marshal.dump(data) begin doc = get( session_id ) doc[:data] = marshaled doc[:updated_at] = Time.now doc.save rescue doc = self.new( '_id' => session_id, :data => marshaled, :created_at => Time.now ) doc.save end end |