]> git.cworth.org Git - sup/commitdiff
respond_to? needs include_private argument
authorDecklin Foster <decklin@red-bean.com>
Wed, 18 Jun 2008 20:25:56 +0000 (16:25 -0400)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Thu, 19 Jun 2008 17:29:02 +0000 (10:29 -0700)
Sup started mysteriously bailing out on me today after an apt-get
update with stuff like this:

 --- ArgumentError from thread: main
wrong number of arguments (2 for 1)
/usr/lib/ruby/1.8/sup/index.rb:424:in `respond_to?'
/usr/lib/ruby/1.8/sup/index.rb:424:in `flatten'
/usr/lib/ruby/1.8/sup/index.rb:424:in `load_sources'
/usr/lib/ruby/1.8/sup/index.rb:108:in `load'
/usr/lib/ruby/1.8/sup/util.rb:497:in `send'
/usr/lib/ruby/1.8/sup/util.rb:497:in `method_missing'
/usr/bin/sup:122

I did some digging and it seems like when Array#flatten, in attempting
to figure out if it can flatten some list element recursively, sends
it :respond_to? with both arguments -- I didn't even know there was a
second one (defaults to false; see docs). But this only happened recently
or something.

Here's somewhere else this came up:
http://www.ruby-forum.com/topic/154938

So, the fix is exactly the same. Should work fine on old Ruby as well.

lib/sup/util.rb

index ceaf0b8dabc8a83ea451005e9b27bc109823caf1..9909022ffa9b0b1c5796f4fbdff925087dec2519 100644 (file)
@@ -108,7 +108,9 @@ class Module
   def defer_all_other_method_calls_to obj
     class_eval %{
       def method_missing meth, *a, &b; @#{obj}.send meth, *a, &b; end
-      def respond_to? meth; @#{obj}.respond_to?(meth); end
+      def respond_to?(m, include_private = false)
+        @#{obj}.respond_to?(m, include_private)
+      end
     }
   end
 end
@@ -527,7 +529,9 @@ class Recoverable
   def to_yaml x; __pass :to_yaml, x; end
   def is_a? c; @o.is_a? c; end
 
-  def respond_to? m; @o.respond_to? m end
+  def respond_to?(m, include_private=false)
+    @o.respond_to?(m, include_private)
+  end
 
   def __pass m, *a, &b
     begin