Skip to content
This repository
Browse code

[fix] "super: no superclass method" on _rhook.to(call_method). - it c…

…ould be Method#call's bug in ruby 1.8.7.
  • Loading branch information...
commit f42258665591c797e848e8a7ab9f68eb22aec87c 1 parent df50e3e
authored January 03, 2011
4  lib/rhook.rb
@@ -145,7 +145,9 @@ def call_method(name, method_name, args, block, opt = {})
145 145
       inv.args = args
146 146
       inv.block = block
147 147
       inv.hooks = hooks
148  
-      inv.target_proc = @obj.method(method_name)
  148
+      inv.target_proc = lambda do |*args, &block|
  149
+        @obj.__send__(method_name, *args, &block)
  150
+      end
149 151
       inv.hint = opt[:hint] || {}
150 152
       inv.proceed()
151 153
     ensure
40  spec/rhook_minor_spec.rb
@@ -146,4 +146,44 @@ def both_on_method_and_to_target
146 146
       end
147 147
     end
148 148
   end
  149
+  
  150
+  # ========================================================================
  151
+  describe "#call_method(#to): " do
  152
+    before :each do
  153
+    end
  154
+    
  155
+    example "[bugfix] super: no superclass method" do
  156
+      class CallMethodSuperTest_Super
  157
+        def the_method
  158
+          
  159
+        end
  160
+      end
  161
+      
  162
+      module CallMethodSuperTest_Module
  163
+        def the_method
  164
+          super
  165
+        end
  166
+      end
  167
+      
  168
+      class CallMethodSuperTest_Inherited < CallMethodSuperTest_Super
  169
+        include CallMethodSuperTest_Module
  170
+      end
  171
+      
  172
+      # This bug does not appear without hooks.
  173
+      CallMethodSuperTest_Inherited._rhook.bind(:the_method) do |inv|
  174
+        inv.call
  175
+      end
  176
+      
  177
+      # OK.
  178
+      CallMethodSuperTest_Inherited.new.the_method
  179
+      
  180
+      # We fixed the bug this cause error:
  181
+      lambda {
  182
+        CallMethodSuperTest_Inherited.new._rhook.to.the_method
  183
+      }.should_not raise_error
  184
+      # - super: no superclass method `the_method'
  185
+    end
  186
+  end
  187
+  # ========================================================================
  188
+  
149 189
 end

0 notes on commit f422586

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