lib/redis/namespace.rb in redis-namespace-1.8.1 vs lib/redis/namespace.rb in redis-namespace-1.8.2

- old
+ new

@@ -490,10 +490,16 @@ result end ruby2_keywords(:call_with_namespace) if respond_to?(:ruby2_keywords, true) + protected + + def redis=(redis) + @redis = redis + end + private if Hash.respond_to?(:ruby2_keywords_hash) def ruby2_keywords_hash(kwargs) Hash.ruby2_keywords_hash(kwargs) @@ -518,15 +524,16 @@ def call_site caller.reject { |l| l.start_with?(__FILE__) }.first end def namespaced_block(command, &block) - redis.send(command) do |r| - begin - original, @redis = @redis, r - yield self - ensure - @redis = original + if block.arity == 0 + redis.send(command, &block) + else + redis.send(command) do |r| + copy = dup + copy.redis = r + yield copy end end end def add_namespace(key)