From 69ab514477b646e082e5f87498c7035bdbc7097c Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Mon, 20 Feb 2017 14:11:32 +0000 Subject: [PATCH] Warn if Redis gem is < 3.0.0 Prefer printing a log message if this criteria is not met, instead of failing silently. --- lib/rack/attack/store_proxy/redis_store_proxy.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/rack/attack/store_proxy/redis_store_proxy.rb b/lib/rack/attack/store_proxy/redis_store_proxy.rb index be3c412..05d9ec8 100644 --- a/lib/rack/attack/store_proxy/redis_store_proxy.rb +++ b/lib/rack/attack/store_proxy/redis_store_proxy.rb @@ -4,6 +4,13 @@ module Rack class Attack module StoreProxy class RedisStoreProxy < SimpleDelegator + def initialize(*args) + major_version = Redis::VERSION.split('.').first.to_i + warn 'RackAttack requires Redis gem >= 3.0.0.' if major_version < 3 + + super(*args) + end + def self.handle?(store) defined?(::Redis::Store) && store.is_a?(::Redis::Store) end