GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Ruby 1.9 compat: use method_defined? instead of instance_methods.include?  
Don't encourage args abuse by flattening.
jeremy (author)
Sat Sep 06 18:45:52 -0700 2008
commit  15b1b2b778ce18ff23737b3a0674780d22605fdf
tree    e6353054979fed0c886cea51ae75dce1b4eb7828
parent  227ee2ecb46f1609938a83ed82abde1a45ebe2eb
...
18
19
20
21
 
22
23
 
 
24
25
 
26
27
28
...
30
31
32
 
33
34
35
36
37
 
...
18
19
20
 
21
22
 
23
24
25
26
27
28
29
30
...
32
33
34
35
36
37
38
 
39
40
0
@@ -18,11 +18,13 @@ class Module
0
       raise ArgumentError, "Synchronization needs a mutex. Supply an options hash with a :with key as the last argument (e.g. synchronize :hello, :with => :@mutex)."
0
     end
0
 
0
- methods.flatten.each do |method|
0
+ methods.each do |method|
0
       aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1
0
- if instance_methods.include?("#{aliased_method}_without_synchronization#{punctuation}")
0
+
0
+ if method_defined?("#{aliased_method}_without_synchronization#{punctuation}")
0
         raise ArgumentError, "#{method} is already synchronized. Double synchronization is not currently supported."
0
       end
0
+
0
       module_eval(<<-EOS, __FILE__, __LINE__)
0
         def #{aliased_method}_with_synchronization#{punctuation}(*args, &block)
0
           #{with}.synchronize do
0
@@ -30,7 +32,8 @@ class Module
0
           end
0
         end
0
       EOS
0
+
0
       alias_method_chain method, :synchronization
0
     end
0
   end
0
-end
0
\ No newline at end of file
0
+end

Comments

  • Shouldn’t the check for preexisting alias_method_chain’d methods be performed by alias_method_chain itself? That would prevent infinite recursions in case the same alias_method_chain call is evaluated more than once (double require’s or load’s).

  • PDI

  • We had this in an earlier commit but it hosed migrations. Odds are it was simply mis-detecting whether the method existed and falling back on the super classes. If you want to take a look it’s in the logs here somewhere.