Skip to content
This repository
Browse code

Revert alias_method_chain exceptions as they broke aliasing class met…

…hods.

This reverts commit be48cad.
  • Loading branch information...
commit 8af98c3f8143d7086e15d4938fd56512ed584f2e 1 parent be48cad
Michael Koziarski authored April 28, 2008
4  activesupport/lib/active_support/core_ext/module/aliasing.rb
@@ -28,10 +28,6 @@ def alias_method_chain(target, feature)
28 28
     
29 29
     with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}"
30 30
     
31  
-    if method_defined?(without_method) || private_method_defined?(without_method)
32  
-      raise NameError, "#{with_method} is already in #{target}'s alias chain."
33  
-    end
34  
-    
35 31
     alias_method without_method, target
36 32
     alias_method target, with_method
37 33
     
15  activesupport/test/core_ext/module_test.rb
@@ -166,19 +166,6 @@ def test_alias_method_chain
166 166
     assert_equal 'bar_with_baz', @instance.bar
167 167
     assert_equal 'bar', @instance.bar_without_baz
168 168
   end
169  
-  
170  
-  def test_alias_method_chain_complains_the_second_time
171  
-    FooClassWithBarMethod.class_eval do
172  
-      def bar_with_magic; end
173  
-      alias_method_chain :bar, :magic
174  
-    end
175  
-    
176  
-    assert_raise(NameError) do
177  
-      FooClassWithBarMethod.class_eval do
178  
-        alias_method_chain :bar, :magic
179  
-      end
180  
-    end
181  
-  end
182 169
 
183 170
   def test_alias_method_chain_with_punctuation_method
184 171
     FooClassWithBarMethod.class_eval do
@@ -302,5 +289,5 @@ def duck; 'duck' end
302 289
 
303 290
     assert_equal 'duck_with_orange', @instance.duck
304 291
     assert FooClassWithBarMethod.public_method_defined?(:duck)
305  
-  end  
  292
+  end
306 293
 end

2 notes on commit 8af98c3

Chad Humphries

You could keep the change, but log the error instead of raising it.

John Barnette

No, this gets triggered by some “proper” behavior in migrations — it needs to be fixed. I’m poking at it later today.

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