From 23cfaf9dec4bc58fd9b3fd8366fb0e087c7f1e51 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Sun, 12 Aug 2012 20:16:28 -0400 Subject: [PATCH] Always define respond_to_missing? when overriding method_missing See: http://robots.thoughtbot.com/post/28335346416/always-define-respond-to-missing-when-overriding --- lib/twitter.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/twitter.rb b/lib/twitter.rb index 8bb243098..169bbe8b8 100644 --- a/lib/twitter.rb +++ b/lib/twitter.rb @@ -16,15 +16,14 @@ def client end end - def respond_to?(method, include_private=false) - self.client.respond_to?(method, include_private) || super - end + def respond_to_missing?(method_name, include_private=false); client.respond_to?(method_name, include_private); end if RUBY_VERSION >= "1.9" + def respond_to?(method_name, include_private=false); client.respond_to?(method_name, include_private) || super; end if RUBY_VERSION < "1.9" private - def method_missing(method, *args, &block) - return super unless self.client.respond_to?(method) - self.client.send(method, *args, &block) + def method_missing(method_name, *args, &block) + return super unless client.respond_to?(method_name) + client.send(method_name, *args, &block) end end