Integrate request_store to help with Threading issues #340

Merged
merged 1 commit into from Mar 3, 2014
View
@@ -4,6 +4,7 @@ PATH
authlogic (3.3.0)
activerecord (>= 3.2)
activesupport (>= 3.2)
+ request_store (~> 1.0.5)
GEM
remote: https://rubygems.org/
@@ -37,6 +38,7 @@ GEM
minitest (4.7.5)
multi_json (1.8.4)
rake (10.1.1)
+ request_store (1.0.5)
scrypt (1.2.0)
ffi-compiler (>= 0.0.2)
rake
View
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
s.add_dependency 'activerecord', '>= 3.2'
s.add_dependency 'activesupport', '>= 3.2'
+ s.add_dependency 'request_store', '~>1.0.5'
s.add_development_dependency 'rake'
s.add_development_dependency 'bcrypt-ruby'
s.add_development_dependency 'scrypt'
@@ -1,3 +1,5 @@
+require 'request_store'
+
module Authlogic
module Session
# Activating Authlogic requires that you pass it an Authlogic::ControllerAdapters::AbstractAdapter object, or a class that extends it.
@@ -32,12 +34,12 @@ def activated?
#
# Lastly, this is thread safe.
def controller=(value)
- Thread.current[:authlogic_controller] = value
+ RequestStore.store[:authlogic_controller] = value
end
# The current controller object
def controller
- Thread.current[:authlogic_controller]
+ RequestStore.store[:authlogic_controller]
end
end
@@ -55,4 +57,4 @@ def controller
end
end
end
-end
+end
@@ -1,3 +1,5 @@
+require 'request_store'
+
module Authlogic
module Session
# Authentication can be scoped, and it's easy, you just need to define how you want to scope everything. This should help you:
@@ -17,7 +19,7 @@ def self.included(klass)
module ClassMethods
# The current scope set, should be used in the block passed to with_scope.
def scope
- Thread.current[:authlogic_scope]
+ RequestStore.store[:authlogic_scope]
end
# What with_scopes focuses on is scoping the query when finding the object and the name of the cookie / session. It works very similar to
@@ -68,7 +70,7 @@ def with_scope(options = {}, &block)
private
def scope=(value)
- Thread.current[:authlogic_scope] = value
+ RequestStore.store[:authlogic_scope] = value
end
end