From 935f99a6386af1a6974d12e80c8512897274146c Mon Sep 17 00:00:00 2001 From: Gonzalo Rodriguez Date: Sun, 30 Sep 2018 22:11:16 -0300 Subject: [PATCH] [Fixes #355] Avoid unexpected 'Gem::LoadError' for redis when not intented to be used It seems that the original implementation accidentally autoloaded ActiveSupport::Cache::RedisCacheStore which once evaluated asks for redis v4 generating Gem::LoadError. In order to bypass any unnecessary constant autoloading we can just check class name string. --- lib/rack/attack/store_proxy/redis_cache_store_proxy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rack/attack/store_proxy/redis_cache_store_proxy.rb b/lib/rack/attack/store_proxy/redis_cache_store_proxy.rb index 2f7296c..78807f8 100644 --- a/lib/rack/attack/store_proxy/redis_cache_store_proxy.rb +++ b/lib/rack/attack/store_proxy/redis_cache_store_proxy.rb @@ -7,7 +7,7 @@ module Rack module StoreProxy class RedisCacheStoreProxy < SimpleDelegator def self.handle?(store) - defined?(::Redis) && defined?(::ActiveSupport::Cache::RedisCacheStore) && store.is_a?(::ActiveSupport::Cache::RedisCacheStore) + store.class.name == "ActiveSupport::Cache::RedisCacheStore" end def increment(name, amount = 1, options = {})