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