mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Use define_method instead of eval-ing a string
It avoids the need for escaping the interpolations.
This commit is contained in:
parent
c5e1dba31f
commit
f00853bee8
1 changed files with 4 additions and 6 deletions
|
@ -25,12 +25,10 @@ class DiscourseRedis
|
||||||
pttl rename renamenx rpop rpoplpush rpush rpushx sadd scard sdiff set setbit setex setnx setrange sinter
|
pttl rename renamenx rpop rpoplpush rpush rpushx sadd scard sdiff set setbit setex setnx setrange sinter
|
||||||
sismember smembers sort spop srandmember srem strlen sunion ttl type watch zadd zcard zcount zincrby
|
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|
|
zrange zrangebyscore zrank zrem zremrangebyrank zremrangebyscore zrevrange zrevrangebyscore zrevrank zrangebyscore).each do |m|
|
||||||
class_eval %{
|
define_method m do |*args|
|
||||||
def #{m}(*args)
|
args[0] = "#{DiscourseRedis.namespace}:#{args[0]}"
|
||||||
args[0] = "\#\{DiscourseRedis.namespace\}:\#\{args[0]\}"
|
@redis.send(__method__, *args)
|
||||||
@redis.#{m}(*args)
|
end
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.namespace
|
def self.namespace
|
||||||
|
|
Loading…
Reference in a new issue