Class: CGI::Session::ActiveRecordStore::Session

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/action_controller/session/active_record_store.rb

Overview

The default Active Record class.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Lazy-unmarshal session state.


119
120
121
# File 'lib/action_controller/session/active_record_store.rb', line 119

def data
  @data ||= self.class.unmarshal(read_attribute(@@data_column_name)) || {}
end

Class Method Details

.create_table!Object


84
85
86
87
88
89
90
91
92
# File 'lib/action_controller/session/active_record_store.rb', line 84

def create_table!
  connection.execute <<-end_sql
    CREATE TABLE #{table_name} (
      id INTEGER PRIMARY KEY,
      #{connection.quote_column_name('session_id')} TEXT UNIQUE,
      #{connection.quote_column_name(@@data_column_name)} TEXT(255)
    )
  end_sql
end

.data_column_size_limitObject


71
72
73
# File 'lib/action_controller/session/active_record_store.rb', line 71

def data_column_size_limit
  @data_column_size_limit ||= columns_hash[@@data_column_name].limit
end

.drop_table!Object


94
95
96
# File 'lib/action_controller/session/active_record_store.rb', line 94

def drop_table!
  connection.execute "DROP TABLE #{table_name}"
end

.find_by_session_id(session_id) ⇒ Object

Hook to set up sessid compatibility.


76
77
78
79
# File 'lib/action_controller/session/active_record_store.rb', line 76

def find_by_session_id(session_id)
  setup_sessid_compatibility!
  find_by_session_id(session_id)
end

.marshal(data) ⇒ Object


81
# File 'lib/action_controller/session/active_record_store.rb', line 81

def marshal(data)   Base64.encode64(Marshal.dump(data)) if data end

.reloadable?Boolean

Don't try to reload ARStore::Session in dev mode.

Returns:

  • (Boolean)

67
68
69
# File 'lib/action_controller/session/active_record_store.rb', line 67

def reloadable? #:nodoc:
  false
end

.unmarshal(data) ⇒ Object


82
# File 'lib/action_controller/session/active_record_store.rb', line 82

def unmarshal(data) Marshal.load(Base64.decode64(data)) if data end

Instance Method Details

#loaded?Boolean

Has the session been loaded yet?

Returns:

  • (Boolean)

124
125
126
# File 'lib/action_controller/session/active_record_store.rb', line 124

def loaded?
  !! @data
end