Skip to content
This repository
Browse code

[BUG] Don't work (syntax error) in some earlier version of Ruby 1.8.

  • Loading branch information...
commit d46decbcecdbe2a7577b8509cb371d7e23b8f82c 1 parent 2ad4aa3
authored

Showing 1 changed file with 16 additions and 3 deletions. Show diff stats Hide diff stats

  1. 19  lib/rhook.rb
19  lib/rhook.rb
@@ -130,6 +130,21 @@ def to(opt = {})
130 130
     end
131 131
     
132 132
     # @private
  133
+    # Used in call_method
  134
+    # Instead of ''lambda { |*args, &block| @obj.__send__(method_name, *args, &block); }''
  135
+    # because some earlier versions of Ruby-1.8 cannot parse it.
  136
+    class MethodCaller
  137
+      def initialize(obj, method_name)
  138
+        @obj = obj
  139
+        @method_name = method_name
  140
+      end
  141
+      
  142
+      def call(*args, &block)
  143
+        @obj.__send__(@method_name, *args, &block)
  144
+      end
  145
+    end #/MethodCaller
  146
+    
  147
+    # @private
133 148
     def call_method(name, method_name, args, block, opt = {})
134 149
       if @last_name_call_method_done == name
135 150
         return @obj.__send__(method_name, *args, &block)
@@ -145,9 +160,7 @@ def call_method(name, method_name, args, block, opt = {})
145 160
       inv.args = args
146 161
       inv.block = block
147 162
       inv.hooks = hooks
148  
-      inv.target_proc = lambda do |*args, &block|
149  
-        @obj.__send__(method_name, *args, &block)
150  
-      end
  163
+      inv.target_proc = MethodCaller.new(@obj, method_name)
151 164
       inv.hint = opt[:hint] || {}
152 165
       inv.proceed()
153 166
     ensure

0 notes on commit d46decb

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