Class: Harbor::Session::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/harbor/session/abstract.rb

Overview

Defines the API and default behavior for session stores. See Cookie, and contrib/session/data_mapper for examples of usage.

Direct Known Subclasses

Contrib::Session::DataMapper, Cookie

Class Method Summary collapse

Class Method Details

.commit_session(data) ⇒ Object

Receives the session data hash, and should return the data to be set for the cookie’s value



21
22
23
# File 'lib/harbor/session/abstract.rb', line 21

def self.commit_session(data)
  [Marshal.dump(data)].pack("m*")
end

.load_session(cookie) ⇒ Object

Receives the raw cookie data, and should return a hash of the data for the session.



13
14
15
# File 'lib/harbor/session/abstract.rb', line 13

def self.load_session(cookie)
  Marshal.load(cookie.unpack("m*")[0]) rescue {}
end