Class: CGI::Session::ActiveRecordStore::Session
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- CGI::Session::ActiveRecordStore::Session
- Defined in:
- lib/action_controller/session/active_record_store.rb
Overview
The default Active Record class.
Instance Attribute Summary collapse
-
#data ⇒ Object
Lazy-unmarshal session state.
Class Method Summary collapse
- .create_table! ⇒ Object
- .data_column_size_limit ⇒ Object
- .drop_table! ⇒ Object
-
.find_by_session_id(session_id) ⇒ Object
Hook to set up sessid compatibility.
- .marshal(data) ⇒ Object
-
.reloadable? ⇒ Boolean
Don’t try to reload ARStore::Session in dev mode.
- .unmarshal(data) ⇒ Object
Instance Method Summary collapse
-
#loaded? ⇒ Boolean
Has the session been loaded yet?.
Instance Attribute Details
#data ⇒ Object
Lazy-unmarshal session state.
121 122 123 |
# File 'lib/action_controller/session/active_record_store.rb', line 121 def data @data ||= self.class.unmarshal(read_attribute(@@data_column_name)) || {} end |
Class Method Details
.create_table! ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/action_controller/session/active_record_store.rb', line 86 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_limit ⇒ Object
73 74 75 |
# File 'lib/action_controller/session/active_record_store.rb', line 73 def data_column_size_limit @data_column_size_limit ||= columns_hash[@@data_column_name].limit end |
.drop_table! ⇒ Object
96 97 98 |
# File 'lib/action_controller/session/active_record_store.rb', line 96 def drop_table! connection.execute "DROP TABLE #{table_name}" end |
.find_by_session_id(session_id) ⇒ Object
Hook to set up sessid compatibility.
78 79 80 81 |
# File 'lib/action_controller/session/active_record_store.rb', line 78 def find_by_session_id(session_id) setup_sessid_compatibility! find_by_session_id(session_id) end |
.marshal(data) ⇒ Object
83 |
# File 'lib/action_controller/session/active_record_store.rb', line 83 def marshal(data) Base64.encode64(Marshal.dump(data)) if data end |
.reloadable? ⇒ Boolean
Don’t try to reload ARStore::Session in dev mode.
69 70 71 |
# File 'lib/action_controller/session/active_record_store.rb', line 69 def reloadable? #:nodoc: false end |
.unmarshal(data) ⇒ Object
84 |
# File 'lib/action_controller/session/active_record_store.rb', line 84 def unmarshal(data) Marshal.load(Base64.decode64(data)) if data end |
Instance Method Details
#loaded? ⇒ Boolean
Has the session been loaded yet?
128 129 130 |
# File 'lib/action_controller/session/active_record_store.rb', line 128 def loaded? !! @data end |