Browse files

session creation methods to a module

  • Loading branch information...
1 parent db93c1c commit 26e7678ab374a730196ae889e31bce2ea0cb0735 @tenderlove tenderlove committed May 4, 2012
View
15 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
@@ -65,19 +65,22 @@ def stale_session_check!
end
end
- class AbstractStore < Rack::Session::Abstract::ID
- include Compatibility
- include StaleSessionCheck
-
- private
-
+ module SessionObject # :nodoc:
def prepare_session(env)
Request::Session.create(self, env, @default_options)
end
def loaded_session?(session)
!session.is_a?(Request::Session) || session.loaded?
end
+ end
+
+ class AbstractStore < Rack::Session::Abstract::ID
+ include Compatibility
+ include StaleSessionCheck
+ include SessionObject
+
+ private
def set_cookie(env, session_id, cookie)
request = ActionDispatch::Request.new(env)
View
9 actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
@@ -43,17 +43,10 @@ module Session
class CookieStore < Rack::Session::Cookie
include Compatibility
include StaleSessionCheck
+ include SessionObject
private
- def prepare_session(env)
- Request::Session.create(self, env, @default_options)
- end
-
- def loaded_session?(session)
- !session.is_a?(Request::Session) || session.loaded?
- end
-
def unpacked_cookie_data(env)
env["action_dispatch.request.unsigned_session_cookie"] ||= begin
stale_session_check! do
View
11 actionpack/lib/action_dispatch/middleware/session/mem_cache_store.rb
@@ -6,22 +6,13 @@ module Session
class MemCacheStore < Rack::Session::Memcache
include Compatibility
include StaleSessionCheck
+ include SessionObject
def initialize(app, options = {})
require 'memcache'
options[:expire_after] ||= options[:expires]
super
end
-
- private
-
- def prepare_session(env)
- Request::Session.create(self, env, @default_options)
- end
-
- def loaded_session?(session)
- !session.is_a?(Request::Session) || session.loaded?
- end
end
end
end

0 comments on commit 26e7678

Please sign in to comment.