Class: Merb::DataMapperSessionStore

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/merb_datamapper/data_mapper_session.rb

Class Method Summary collapse

Class Method Details

.default_repository_nameObject



7
8
9
# File 'lib/merb_datamapper/data_mapper_session.rb', line 7

def self.default_repository_name
  Merb::Plugins.config[:merb_datamapper][:session_repository_name]
end

.delete_session(session_id) ⇒ Object

Deletes a session with the given id

Parameters:

  • session_id (String)

    The session to destroy



47
48
49
# File 'lib/merb_datamapper/data_mapper_session.rb', line 47

def self.delete_session(session_id)
  all(:session_id => session_id).destroy!
end

.retrieve_session(session_id) ⇒ Object

Retrieves a session from the session store

Parameters:

  • session_id (String)

    The session_id to retrieve the session for



23
24
25
26
27
# File 'lib/merb_datamapper/data_mapper_session.rb', line 23

def self.retrieve_session(session_id)
  if session = get(session_id)
    session.data
  end
end

.store_session(session_id, data) ⇒ Object

Stores the data in a session with the given session_id, creating it if required

Parameters:

  • session_id (String)

    The session_id to find the session by, or the id of the new session

  • data (Object)

    The data to be stored in the session. Probably a hash



35
36
37
38
39
40
41
# File 'lib/merb_datamapper/data_mapper_session.rb', line 35

def self.store_session(session_id, data)
  if session = get(session_id)
    session.update(:data => data)
  else
    create(:session_id => session_id, :data => data)
  end
end