Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't proxy #eval as it raises TypeError on nested namespaces #67

Merged
merged 1 commit into from
Oct 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/redis/namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ def exec
method_missing(:exec)
end

def eval(*args)
method_missing(:eval, *args)
end

def method_missing(command, *args, &block)
handling = COMMANDS[command.to_s] ||
COMMANDS[ALIASES[command.to_s]]
Expand Down
15 changes: 15 additions & 0 deletions spec/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,21 @@
should eq(%w[ns:k1 ns:k2])
end
end

context "in a nested namespace" do
let(:nested_namespace) { Redis::Namespace.new(:nest, :redis => @namespaced) }
let(:sha) { nested_namespace.script(:load, "return {KEYS[1], KEYS[2]}") }

it "should namespace eval keys passed in as hash args" do
nested_namespace.
eval("return {KEYS[1], KEYS[2]}", :keys => %w[k1 k2], :argv => %w[arg1 arg2]).
should eq(%w[ns:nest:k1 ns:nest:k2])
end
it "should namespace evalsha keys passed in as hash args" do
nested_namespace.evalsha(sha, :keys => %w[k1 k2], :argv => %w[arg1 arg2]).
should eq(%w[ns:nest:k1 ns:nest:k2])
end
end
end
end

Expand Down