From 92be2791ab7824c6eb5d984311c529d48f344f6c Mon Sep 17 00:00:00 2001 From: hakanensari Date: Tue, 1 Apr 2014 12:23:10 +0100 Subject: [PATCH] Handle older Dalli clients --- lib/rack/attack/store_proxy.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rack/attack/store_proxy.rb b/lib/rack/attack/store_proxy.rb index ac7dda9..4b9a6c0 100644 --- a/lib/rack/attack/store_proxy.rb +++ b/lib/rack/attack/store_proxy.rb @@ -14,9 +14,11 @@ module Rack if defined?(::Redis::Store) && store.is_a?(::Redis::Store) RedisStoreProxy.new(store) - elsif store.respond_to?(:with) + elsif defined?(::Dalli) && store.is_a?(::Dalli::Client) + DalliProxy.new(store) + elsif defined?(::ConnectionPool) && store.is_a?(::ConnectionPool) store.with do |conn| - if defined?(::Dalli) && conn.is_a?(::Dalli::Client) + if conn.is_a?(::Dalli::Client) DalliProxy.new(store) else raise NotImplementedError