Class: Harbor::Contrib::Session::DataMapper
- Inherits:
-
Session::Abstract
- Object
- Session::Abstract
- Harbor::Contrib::Session::DataMapper
- Defined in:
- lib/harbor/contrib/session/data_mapper.rb
Overview
This is a database backed session handle for DataMapper. You can use it instead of the builtin Harbor::Session::Cookie by doing:
Harbor::Session.configure do |session|
session.store = Harbor::Contrib::Session::DataMapper
end
A basic Session resource is defined for you.
Defined Under Namespace
Classes: SessionHash
Class Method Summary collapse
Class Method Details
.commit_session(data) ⇒ Object
57 58 59 60 61 |
# File 'lib/harbor/contrib/session/data_mapper.rb', line 57 def self.commit_session(data) record = data.instance record.update_attributes(:data => data.to_hash) record.id end |
.load_session(cookie) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/harbor/contrib/session/data_mapper.rb', line 45 def self.load_session() session = if expire_after = Harbor::Session.[:expire_after] ::Session.first(:id => , :created_at.gte => Time.now - expire_after) else ::Session.get() end session ||= ::Session.create SessionHash.new(session) end |