Skip to content
This repository
Browse code

Ruby 1.9: fix Relation respond_to? and method_missing

  • Loading branch information...
commit 5fa497abf5b885187130e58aefcb1c3228295e3c 1 parent 77478f2
Jeremy Kemper authored November 10, 2009
10  activerecord/lib/active_record/relation.rb
@@ -110,19 +110,17 @@ def conditions(conditions)
110 110
     end
111 111
 
112 112
     def respond_to?(method)
113  
-      if @relation.respond_to?(method) || Array.instance_methods.include?(method.to_s)
114  
-        true
115  
-      else
116  
-        super
117  
-      end
  113
+      @relation.respond_to?(method) || Array.method_defined?(method) || super
118 114
     end
119 115
 
120 116
     private
121 117
       def method_missing(method, *args, &block)
122 118
         if @relation.respond_to?(method)
123 119
           @relation.send(method, *args, &block)
124  
-        elsif Array.instance_methods.include?(method.to_s)
  120
+        elsif Array.method_defined?(method)
125 121
           to_a.send(method, *args, &block)
  122
+        else
  123
+          super
126 124
         end
127 125
       end
128 126
   end

0 notes on commit 5fa497a

Please sign in to comment.
Something went wrong with that request. Please try again.