Permalink
Browse files

Update redis panel to be compatible with older and newer versions of …

…redis-rb gem
  • Loading branch information...
Luke Melia
Luke Melia committed May 29, 2010
1 parent 8f7404d commit 984d62a06cd504d91f434267be8de05641fff840
Showing with 19 additions and 5 deletions.
  1. +19 −5 lib/rack/bug/panels/redis_panel/redis_extension.rb
@@ -2,13 +2,27 @@
if defined?(Redis)
Redis.class_eval do
+ if Redis.methods.include?('call_command') # older versions of redis-rb
+ def call_command_with_rack_bug(*argv)
+ Rack::Bug::RedisPanel.record(argv, Kernel.caller) do
+ call_command_without_rack_bug(*argv)
+ end
+ end
+
+ alias_method_chain :call_command, :rack_bug
+
+ elsif defined?(Redis::Client) # newer versions of redis-rb
+
+ Redis::Client.class_eval do
+ def call_with_rack_bug(*argv)
+ Rack::Bug::RedisPanel.record(argv, Kernel.caller) do
+ call_without_rack_bug(*argv)
+ end
+ end
+
+ alias_method_chain :call, :rack_bug
- def call_command_with_rack_bug(argv)
- Rack::Bug::RedisPanel.record(argv, Kernel.caller) do
- call_command_without_rack_bug(argv)
end
end
-
- alias_method_chain :call_command, :rack_bug
end
end

0 comments on commit 984d62a

Please sign in to comment.