Module: ActiveRecord::SessionStore::ClassMethods

Included in:
Session, SqlBypass
Defined in:
lib/active_record/session_store.rb

Overview

:nodoc:

Defined Under Namespace

Classes: HybridSerializer, JsonSerializer, MarshalSerializer, NullSerializer

Instance Method Summary collapse

Instance Method Details

#create_table!Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active_record/session_store.rb', line 29

def create_table!
  if connection.schema_cache.respond_to?(:clear_data_source_cache!)
    connection.schema_cache.clear_data_source_cache!(table_name)
  else
    connection.schema_cache.clear_table_cache!(table_name)
  end
  connection.create_table(table_name) do |t|
    t.string session_id_column, :limit => 255
    t.text data_column_name
  end
  connection.add_index table_name, session_id_column, :unique => true
end

#deserialize(data) ⇒ Object



16
17
18
# File 'lib/active_record/session_store.rb', line 16

def deserialize(data)
  serializer_class.load(data) if data
end

#drop_table!Object



20
21
22
23
24
25
26
27
# File 'lib/active_record/session_store.rb', line 20

def drop_table!
  if connection.schema_cache.respond_to?(:clear_data_source_cache!)
    connection.schema_cache.clear_data_source_cache!(table_name)
  else
    connection.schema_cache.clear_table_cache!(table_name)
  end
  connection.drop_table table_name
end

#serialize(data) ⇒ Object



12
13
14
# File 'lib/active_record/session_store.rb', line 12

def serialize(data)
  serializer_class.dump(data) if data
end

#serializer_classObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/active_record/session_store.rb', line 42

def serializer_class
  case self.serializer
    when :marshal, nil then
      MarshalSerializer
    when :json then
      JsonSerializer
    when :hybrid then
      HybridSerializer
    when :null then
      NullSerializer
    else
      self.serializer
  end
end