Skip to content

Commit

Permalink
fix: check whether client class is defined before checking client itself
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Boisard committed Dec 29, 2015
1 parent 297ef4a commit 32df84d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/rack/attack/store_proxy.rb
Expand Up @@ -12,9 +12,10 @@ def self.build(store)
# ActiveSupport::Cache::RedisStore doesn't expose any way to set an expiry,
# so use the raw Redis::Store instead.
# We also want to use the underlying Dalli client instead of ::ActiveSupport::Cache::MemCacheStore,
# but not the Memcache client if using Rails 3.x
# and the MemCache client if using Rails 3.x
client = store.instance_variable_get(:@data)
if client.is_a?(Redis::Store) || client.is_a?(Dalli::Client) || client.is_a?(MemCache)
if (defined?(::Redis::Store) && client.is_a?(Redis::Store)) ||
(defined?(Dalli::Client) && client.is_a?(Dalli::Client)) || (defined?(MemCache) && client.is_a?(MemCache))
store = store.instance_variable_get(:@data)
end
end
Expand Down

0 comments on commit 32df84d

Please sign in to comment.