mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-04-14 12:46:01 +00:00
fix: check whether client class is defined before checking client itself
This commit is contained in:
parent
297ef4a2ae
commit
32df84df54
1 changed files with 3 additions and 2 deletions
|
|
@ -12,9 +12,10 @@ module Rack
|
||||||
# ActiveSupport::Cache::RedisStore doesn't expose any way to set an expiry,
|
# ActiveSupport::Cache::RedisStore doesn't expose any way to set an expiry,
|
||||||
# so use the raw Redis::Store instead.
|
# so use the raw Redis::Store instead.
|
||||||
# We also want to use the underlying Dalli client instead of ::ActiveSupport::Cache::MemCacheStore,
|
# 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)
|
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)
|
store = store.instance_variable_get(:@data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue