Class: ActiveRecord::SessionStore::Session

Inherits:
Base show all
Extended by:
ClassMethods
Defined in:
activerecord/lib/active_record/session_store.rb

Overview

The default Active Record class.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

create_table!, drop_table!, marshal, unmarshal

Methods inherited from Base

#<=>, #==, ===, abstract_class?, arel_engine, arel_table, #assign_attributes, attr_readonly, #attribute_for_inspect, attribute_method?, #attribute_names, attribute_names, #attribute_present?, #attributes, #attributes=, base_class, before_remove_const, #cache_key, clear_active_connections!, clear_cache!, column_defaults, #column_for_attribute, column_methods_hash, column_names, columns, columns_hash, #configurations, connected?, #connection, connection, connection_config, #connection_handler, connection_pool, content_columns, count_by_sql, create, #default_timezone, descends_from_active_record?, #dup, #encode_with, establish_connection, find_by_sql, finder_needs_type_condition?, #freeze, #frozen?, full_table_name_prefix, #has_attribute?, #hash, i18n_scope, inheritance_column, #init_with, #initialize_dup, inspect, #inspect, instantiate, #logger, lookup_ancestors, mysql2_connection, mysql_connection, #pluralize_table_names, postgresql_connection, #primary_key_prefix_type, quote_value, #quoted_id, quoted_table_name, #readonly!, #readonly?, readonly_attributes, remove_connection, reset_column_information, reset_sequence_name, reset_table_name, respond_to?, retrieve_connection, sanitize, #schema_format, sequence_name, serialize, set_inheritance_column, set_sequence_name, set_table_name, sqlite3_connection, sti_name, symbolized_base_class, symbolized_sti_name, table_exists?, table_name, #table_name_prefix, #table_name_suffix, #timestamped_migrations, #to_param, unscoped

Constructor Details

#initialize(attributes = nil, options = {}) ⇒ Session

Returns a new instance of Session.



128
129
130
131
# File 'activerecord/lib/active_record/session_store.rb', line 128

def initialize(attributes = nil, options = {})
  @data = nil
  super
end

Instance Attribute Details

#dataObject

Lazy-unmarshal session state.



134
135
136
# File 'activerecord/lib/active_record/session_store.rb', line 134

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

Class Method Details

.data_column_size_limitObject



92
93
94
# File 'activerecord/lib/active_record/session_store.rb', line 92

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

.find_by_session_id(session_id) ⇒ Object

Hook to set up sessid compatibility.



97
98
99
100
# File 'activerecord/lib/active_record/session_store.rb', line 97

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

Instance Method Details

#data_column_nameObject

:singleton-method: Customizable data column name. Defaults to ‘data’.



83
# File 'activerecord/lib/active_record/session_store.rb', line 83

cattr_accessor :data_column_name

#loaded?Boolean

Has the session been loaded yet?

Returns:

  • (Boolean)


141
142
143
# File 'activerecord/lib/active_record/session_store.rb', line 141

def loaded?
  @data
end