mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
Cleanup unnecessary self references
This commit is contained in:
parent
6f545e2665
commit
b7eb7851cf
2 changed files with 10 additions and 8 deletions
|
|
@ -115,7 +115,7 @@ class Rack::Attack
|
|||
|
||||
def blacklisted_response
|
||||
warn "[DEPRECATION] 'Rack::Attack.blacklisted_response' is deprecated. Please use 'blocklisted_response' instead."
|
||||
self.blocklisted_response
|
||||
blocklisted_response
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,31 +13,33 @@ module Rack
|
|||
end
|
||||
|
||||
def read(key)
|
||||
self.get(key, raw: true)
|
||||
get(key, raw: true)
|
||||
rescue Redis::BaseError
|
||||
end
|
||||
|
||||
def write(key, value, options={})
|
||||
if (expires_in = options[:expires_in])
|
||||
self.setex(key, expires_in, value, raw: true)
|
||||
setex(key, expires_in, value, raw: true)
|
||||
else
|
||||
self.set(key, value, raw: true)
|
||||
set(key, value, raw: true)
|
||||
end
|
||||
rescue Redis::BaseError
|
||||
end
|
||||
|
||||
def increment(key, amount, options={})
|
||||
count = nil
|
||||
self.pipelined do
|
||||
count = self.incrby(key, amount)
|
||||
self.expire(key, options[:expires_in]) if options[:expires_in]
|
||||
|
||||
pipelined do
|
||||
count = incrby(key, amount)
|
||||
expire(key, options[:expires_in]) if options[:expires_in]
|
||||
end
|
||||
|
||||
count.value if count
|
||||
rescue Redis::BaseError
|
||||
end
|
||||
|
||||
def delete(key, options={})
|
||||
self.del(key)
|
||||
del(key)
|
||||
rescue Redis::BaseError
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue