Fix: Support Ruby 3 keyword arguments for DiscourseRedis (#14444)

This commit is contained in:
Yasuo Honda 2021-09-28 11:11:18 +09:00 committed by GitHub
parent cd64e88711
commit d06d09f479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -37,7 +37,7 @@ class DiscourseRedis
end
# prefix the key with the namespace
def method_missing(meth, *args, &block)
def method_missing(meth, *args, **kwargs, &block)
if @redis.respond_to?(meth)
DiscourseRedis.ignore_readonly { @redis.public_send(meth, *args, &block) }
else
@ -54,9 +54,9 @@ class DiscourseRedis
:sdiff, :set, :setbit, :setex, :setnx, :setrange, :sinter, :sismember, :smembers, :sort, :spop, :srandmember, :srem, :strlen,
:sunion, :ttl, :type, :watch, :zadd, :zcard, :zcount, :zincrby, :zrange, :zrangebyscore, :zrank, :zrem, :zremrangebyrank,
:zremrangebyscore, :zrevrange, :zrevrangebyscore, :zrevrank, :zrangebyscore ].each do |m|
define_method m do |*args|
define_method m do |*args, **kwargs|
args[0] = "#{namespace}:#{args[0]}" if @namespace
DiscourseRedis.ignore_readonly { @redis.public_send(m, *args) }
DiscourseRedis.ignore_readonly { @redis.public_send(m, *args, **kwargs) }
end
end