From 995167ec2eced73f44d4f961349dbbee6b297210 Mon Sep 17 00:00:00 2001 From: Marcel Molina Date: Sat, 29 Apr 2006 20:13:27 +0000 Subject: Strip out punctuation on predicates or bang methods being aliased with alias_method_chain since target?_without_feature is not a valid method name. Add tests for Module#alias_method_chain. [Marcel Molina Jr.] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4311 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/module/aliasing.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/core_ext/module') diff --git a/activesupport/lib/active_support/core_ext/module/aliasing.rb b/activesupport/lib/active_support/core_ext/module/aliasing.rb index a80ff0f26d..1f904377df 100644 --- a/activesupport/lib/active_support/core_ext/module/aliasing.rb +++ b/activesupport/lib/active_support/core_ext/module/aliasing.rb @@ -10,7 +10,10 @@ class Module # # And both aliases are set up for you. def alias_method_chain(target, feature) - alias_method "#{target}_without_#{feature}", target - alias_method target, "#{target}_with_#{feature}" + # Strip out punctuation on predicates or bang methods since + # e.g. target?_without_feature is not a valid method name. + aliased_target = target.to_s.sub(/[?!]/, '') + alias_method "#{aliased_target}_without_#{feature}", target + alias_method target, "#{aliased_target}_with_#{feature}" end end -- cgit v1.2.3