Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Using autoload to require the different session stores #8

Merged
merged 1 commit into from Sep 23, 2011
Jump to file or symbol
Failed to load files and symbols.
+40 −48
Split
@@ -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