Permalink
Browse files

Using autoload to require the different session stores

  • Loading branch information...
Arvid Andersson
Arvid Andersson committed Sep 20, 2011
1 parent f052e0c commit 66baa116fe3be42f89a234ac2436c02ff717b9b4
@@ -27,6 +27,6 @@ def self.collection_name
self.collection_name = "sessions"
end
require 'mongo_session_store/mongo_mapper_store'
require 'mongo_session_store/mongoid_store'
require 'mongo_session_store/mongo_store'
autoload :MongoMapperStore,'mongo_session_store/mongo_mapper_store'
autoload :MongoidStore, 'mongo_session_store/mongoid_store'
autoload :MongoStore, 'mongo_session_store/mongo_store'
@@ -1,26 +1,22 @@
begin
require 'mongo_mapper'
require 'mongo_session_store/mongo_store_base'
require 'mongo_mapper'
require 'mongo_session_store/mongo_store_base'
module ActionDispatch
module Session
class MongoMapperStore < MongoStoreBase
class Session
include MongoMapper::Document
set_collection_name MongoSessionStore.collection_name
key :_id, String
key :data, Binary, :default => Marshal.dump({})
timestamps!
end
module ActionDispatch
module Session
class MongoMapperStore < MongoStoreBase
class Session
include MongoMapper::Document
set_collection_name MongoSessionStore.collection_name
key :_id, String
key :data, Binary, :default => Marshal.dump({})
timestamps!
end
end
end
end
MongoMapperStore = ActionDispatch::Session::MongoMapperStore
rescue LoadError
end
MongoMapperStore = ActionDispatch::Session::MongoMapperStore
@@ -1,31 +1,27 @@
begin
require 'mongoid'
require 'mongo_session_store/mongo_store_base'
require 'mongoid'
require 'mongo_session_store/mongo_store_base'
module ActionDispatch
module Session
class MongoidStore < MongoStoreBase
class Session
include Mongoid::Document
include Mongoid::Timestamps
self.collection_name = MongoSessionStore.collection_name
identity :type => String
module ActionDispatch
module Session
class MongoidStore < MongoStoreBase
field :data, :type => BSON::Binary, :default => BSON::Binary.new(Marshal.dump({}))
end
class Session
include Mongoid::Document
include Mongoid::Timestamps
self.collection_name = MongoSessionStore.collection_name
private
def pack(data)
BSON::Binary.new(Marshal.dump(data))
end
identity :type => String
field :data, :type => BSON::Binary, :default => BSON::Binary.new(Marshal.dump({}))
end
private
def pack(data)
BSON::Binary.new(Marshal.dump(data))
end
end
end
MongoidStore = ActionDispatch::Session::MongoidStore
end
rescue LoadError
end
MongoidStore = ActionDispatch::Session::MongoidStore

0 comments on commit 66baa11

Please sign in to comment.