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.

Constant Summary

Constants included from AutosaveAssociation

AutosaveAssociation::ASSOCIATION_TYPES

Constants included from Callbacks

Callbacks::CALLBACKS

Constants included from ActiveModel::AttributeMethods

ActiveModel::AttributeMethods::CALL_COMPILABLE_REGEXP, ActiveModel::AttributeMethods::NAME_COMPILABLE_REGEXP

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 Explain

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

Methods included from CounterCache

#decrement_counter, #increment_counter, #reset_counters, #update_counters

Methods included from DynamicMatchers

#respond_to?

Methods included from Translation

#i18n_scope, #lookup_ancestors

Methods included from ActiveModel::Translation

#human_attribute_name, #i18n_scope, #lookup_ancestors

Methods included from ActiveModel::Naming

#model_name, param_key, plural, route_key, singular, singular_route_key, uncountable?

Methods included from Querying

#count_by_sql, #find_by_sql

Methods included from ActiveSupport::DescendantsTracker

clear, descendants, #descendants, #direct_descendants, direct_descendants, #inherited

Methods included from ActiveSupport::Benchmarkable

#benchmark, #silence

Methods included from QueryCache::ClassMethods

#cache, #uncached

Methods included from Aggregations

#clear_aggregation_cache

Methods included from ActiveSupport::Concern

#append_features, extended, #included

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 ActiveModel::Serializers::Xml

#from_xml, #to_xml

Methods included from ActiveModel::Serialization

#serializable_hash

Methods included from ActiveModel::Serializers::JSON

#as_json, #from_json

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 ActiveSupport::Autoload

#autoload, #autoload_at, #autoload_under, #autoloads, #eager_autoload, eager_autoload!

Methods included from ActiveModel::AttributeMethods

#attribute_missing, #method_missing, #respond_to?, #respond_to_without_attributes?

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 ActiveModel::Validations

#dup, #errors, #initialize_dup, #invalid?, #valid?, #validates_with

Methods included from ActiveSupport::Callbacks

#run_callbacks

Methods included from Integration

#cache_key, #to_param

Methods included from ActiveModel::Conversion

#to_key, #to_model, #to_param, #to_partial_path

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 'activerecord/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 'activerecord/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 'activerecord/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 'activerecord/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 'activerecord/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 'activerecord/lib/active_record/session_store.rb', line 143

def loaded?
  @data
end