Class: ActiveRecord::SessionStore::Session

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

Overview

The default Active Record class.

Constant Summary

Constants included from AutosaveAssociation

AutosaveAssociation::ASSOCIATION_TYPES

Constants included from Callbacks

Callbacks::CALLBACKS

Instance Attribute Summary collapse

Attributes included from Associations

#association_cache

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

create_table!, drop_table!, marshal, unmarshal

Methods inherited from Base

#<=>, #==, ===, arel_engine, arel_table, clear_active_connections!, #configurations, connected?, #connection, connection, connection_config, #connection_handler, connection_id, connection_id=, connection_pool, #default_timezone, #dup, #encode_with, establish_connection, #freeze, #frozen?, generated_feature_methods, #hash, inherited, #init_with, #initialize_dup, initialize_generated_modules, #inspect, inspect, #logger, mysql2_connection, mysql_connection, postgresql_connection, #readonly!, #readonly?, remove_connection, retrieve_connection, #schema_format, sqlite3_connection, #timestamped_migrations, #to_yaml, #yaml_initialize

Methods included from QueryCache::ClassMethods

#cache, #uncached

Methods included from Querying

#count_by_sql, #find_by_sql

Methods included from Translation

#i18n_scope, #lookup_ancestors

Methods included from DynamicMatchers

#respond_to?

Methods included from CounterCache

#decrement_counter, #increment_counter, #reset_counters, #update_counters

Methods included from Explain

#collecting_queries_for_explain, #exec_explain, extended, #logging_query_plan, #silence_auto_explain

Methods included from Aggregations

#clear_aggregation_cache

Methods included from Transactions

#add_to_transaction, #committed!, #destroy, #rollback_active_record_state!, #rolledback!, #save, #save!, #transaction, #with_transaction_returning_status

Methods included from ActiveRecord::Serialization

#serializable_hash, #to_xml

Methods included from AutosaveAssociation

#changed_for_autosave?, #mark_for_destruction, #marked_for_destruction?, #reload

Methods included from NestedAttributes

#_destroy

Methods included from IdentityMap

add, clear, enabled, enabled=, get, #reinit_with, remove, remove_by_id, repository, use, without

Methods included from Associations

#association, #clear_association_cache

Methods included from Callbacks

#destroy, #touch

Methods included from Timestamp

#initialize_dup

Methods included from AttributeMethods

#attribute_for_inspect, #attribute_missing, #attribute_names, #attribute_present?, #attributes, #column_for_attribute, #has_attribute?, #method_missing, #respond_to?

Methods included from Locking::Optimistic

#locking_enabled?

Methods included from Locking::Pessimistic

#lock!, #with_lock

Methods included from Validations

#save, #save!, #valid?

Methods included from Integration

#cache_key, #to_param

Methods included from AttributeAssignment

#assign_attributes, #attributes=

Methods included from ActiveRecord::Sanitization

#quoted_id

Methods included from ActiveRecord::Scoping

#populate_with_current_scope_attributes

Methods included from Persistence

#becomes, #decrement, #decrement!, #delete, #destroy, #destroyed?, #increment, #increment!, #new_record?, #persisted?, #reload, #save, #save!, #toggle, #toggle!, #touch, #update_attribute, #update_attributes, #update_attributes!, #update_column

Constructor Details

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

Returns a new instance of Session.



130
131
132
133
# File 'lib/active_record/session_store.rb', line 130

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveRecord::AttributeMethods

Instance Attribute Details

#dataObject

Lazy-unmarshal session state.



136
137
138
# File 'lib/active_record/session_store.rb', line 136

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

Class Method Details

.data_column_size_limitObject



94
95
96
# File 'lib/active_record/session_store.rb', line 94

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.



99
100
101
102
# File 'lib/active_record/session_store.rb', line 99

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’.



85
# File 'lib/active_record/session_store.rb', line 85

cattr_accessor :data_column_name

#loaded?Boolean

Has the session been loaded yet?

Returns:

  • (Boolean)


143
144
145
# File 'lib/active_record/session_store.rb', line 143

def loaded?
  @data
end