diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-22 23:40:39 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-22 23:40:39 -0700 |
commit | da37716c35ec5007c028c533d64cea0dc80f574b (patch) | |
tree | e8bbddd754f6d926eb8342806b857ba70662a7e1 /activerecord/lib | |
parent | b378b19430a4d2ee54cbe7f1935fbd4f8b3b331b (diff) | |
download | rails-da37716c35ec5007c028c533d64cea0dc80f574b.tar.gz rails-da37716c35ec5007c028c533d64cea0dc80f574b.tar.bz2 rails-da37716c35ec5007c028c533d64cea0dc80f574b.zip |
refactoring class methods to a module
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/session_store.rb | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/activerecord/lib/active_record/session_store.rb b/activerecord/lib/active_record/session_store.rb index 923fab27b0..143c1fec13 100644 --- a/activerecord/lib/active_record/session_store.rb +++ b/activerecord/lib/active_record/session_store.rb @@ -49,8 +49,24 @@ module ActiveRecord # The example SqlBypass class is a generic SQL session store. You may # use it as a basis for high-performance database-specific stores. class SessionStore < ActionDispatch::Session::AbstractStore + module ClassMethods # :nodoc: + def marshal(data) + ActiveSupport::Base64.encode64(Marshal.dump(data)) if data + end + + def unmarshal(data) + Marshal.load(ActiveSupport::Base64.decode64(data)) if data + end + + def drop_table! + connection.execute "DROP TABLE #{table_name}" + end + end + # The default Active Record class. class Session < ActiveRecord::Base + extend ClassMethods + ## # :singleton-method: # Customizable data column name. Defaults to 'data'. @@ -71,14 +87,6 @@ module ActiveRecord find_by_session_id(session_id) end - def marshal(data) - ActiveSupport::Base64.encode64(Marshal.dump(data)) if data - end - - def unmarshal(data) - Marshal.load(ActiveSupport::Base64.decode64(data)) if data - end - def create_table! connection.execute <<-end_sql CREATE TABLE #{table_name} ( @@ -89,10 +97,6 @@ module ActiveRecord end_sql end - def drop_table! - connection.execute "DROP TABLE #{table_name}" - end - private def session_id_column 'session_id' @@ -173,6 +177,8 @@ module ActiveRecord # binary session data in a +text+ column. For higher performance, # store in a +blob+ column instead and forgo the Base64 encoding. class SqlBypass + extend ClassMethods + ## # :singleton-method: # Use the ActiveRecord::Base.connection by default. @@ -208,14 +214,6 @@ module ActiveRecord end end - def marshal(data) - ActiveSupport::Base64.encode64(Marshal.dump(data)) if data - end - - def unmarshal(data) - Marshal.load(ActiveSupport::Base64.decode64(data)) if data - end - def create_table! connection.execute <<-end_sql CREATE TABLE #{table_name} ( @@ -225,10 +223,6 @@ module ActiveRecord ) end_sql end - - def drop_table! - connection.execute "DROP TABLE #{table_name}" - end end attr_reader :session_id, :new_record |