lib/redis/objects.rb in redis-objects-1.4.0 vs lib/redis/objects.rb in redis-objects-1.4.2

- old
+ new

@@ -59,14 +59,15 @@ class NotConnected < StandardError; end class NilObjectId < StandardError; end class << self def redis=(conn) - @redis = Objects::ConnectionPoolProxy.proxy_if_needed(conn) + Thread.current[:__redis_objects_redis] = Objects::ConnectionPoolProxy.proxy_if_needed(conn) end + def redis - @redis || $redis || Redis.current || + Thread.current[:__redis_objects_redis] || $redis || Redis.current || raise(NotConnected, "Redis::Objects.redis not set to a Redis.new connection") end def included(klass) # Core (this file) @@ -88,14 +89,14 @@ # Class methods that appear in your class when you include Redis::Objects. module ClassMethods # Enable per-class connections (eg, User and Post can use diff redis-server) def redis=(conn) - @redis = Objects::ConnectionPoolProxy.proxy_if_needed(conn) + Thread.current[:__redis_objects_redis] = Objects::ConnectionPoolProxy.proxy_if_needed(conn) end def redis - @redis || Objects.redis + Thread.current[:__redis_objects_redis] || Objects.redis end # Internal list of objects attr_writer :redis_objects def redis_objects