Class

ActiveRecord::SessionStore::SqlBypass

Inheritance
< Object

A barebones session store which duck-types with the default session store but bypasses Active Record and issues SQL directly. This is an example session model class meant as a basis for your own classes.

The database connection, table name, and session id and data columns are configurable class attributes. Marshaling and unmarshaling are implemented as class methods that you may override. By default, marshaling data is

  ActiveSupport::Base64.encode64(Marshal.dump(data))

and unmarshaling data is

  Marshal.load(ActiveSupport::Base64.decode64(data))

This marshaling behavior is intended to store the widest range of binary session data in a text column. For higher performance, store in a blob column instead and forgo the Base64 encoding.

Attributes

Name Visibility R/W Description
data public W
session_id public R

Methods

Class

Visibility Signature
public connection ()
public create_table! ()
public drop_table! ()
public find_by_session_id (session_id)
public marshal (data)
public new (attributes)
public unmarshal (data)

Instance

Visibility Signature
public data ()
public destroy ()
public loaded? ()
public new_record? ()
public save ()

Class Method Detail

connection()

create_table!()

drop_table!()

find_by_session_id(session_id)

Look up a session by id and unmarshal its data if found.

marshal(data)

new(attributes)

Look for normal and marshaled data, self.find_by_session_id‘s way of telling us to postpone unmarshaling until the data is requested. We need to handle a normal data attribute in case of a new record.

unmarshal(data)

Instance Method Detail

data()

Lazy-unmarshal session state.

destroy()

loaded?()

new_record?()

save()