Browse files

refactoring more methods to a class methods module

  • Loading branch information...
1 parent da37716 commit 34ff74f44819f6b5c07f5a2c17402010f414695a @tenderlove tenderlove committed Jul 22, 2010
Showing with 12 additions and 20 deletions.
  1. +12 −20 activerecord/lib/active_record/session_store.rb
View
32 activerecord/lib/active_record/session_store.rb
@@ -61,6 +61,16 @@ def unmarshal(data)
def drop_table!
connection.execute "DROP TABLE #{table_name}"
end
+
+ def create_table!
+ connection.execute <<-end_sql
+ CREATE TABLE #{table_name} (
+ id #{connection.type_to_sql(:primary_key)},
+ #{connection.quote_column_name(session_id_column)} VARCHAR(255) UNIQUE,
+ #{connection.quote_column_name(data_column_name)} TEXT
+ )
+ end_sql
+ end
end
# The default Active Record class.
@@ -87,16 +97,6 @@ def find_by_session_id(session_id)
find_by_session_id(session_id)
end
- def create_table!
- connection.execute <<-end_sql
- CREATE TABLE #{table_name} (
- id #{connection.type_to_sql(:primary_key)},
- #{connection.quote_column_name(session_id_column)} VARCHAR(255) UNIQUE,
- #{connection.quote_column_name(data_column_name)} TEXT
- )
- end_sql
- end
-
private
def session_id_column
'session_id'
@@ -203,6 +203,8 @@ class SqlBypass
@@data_column = 'data'
class << self
+ alias :data_column_name :data_column
+
def connection
@@connection ||= ActiveRecord::Base.connection
end
@@ -213,16 +215,6 @@ def find_by_session_id(session_id)
new(:session_id => session_id, :marshaled_data => record['data'])
end
end
-
- def create_table!
- connection.execute <<-end_sql
- CREATE TABLE #{table_name} (
- id #{connection.type_to_sql(:primary_key)},
- #{connection.quote_column_name(session_id_column)} VARCHAR(255) UNIQUE,
- #{connection.quote_column_name(data_column)} TEXT
- )
- end_sql
- end
end
attr_reader :session_id, :new_record

0 comments on commit 34ff74f

Please sign in to comment.