aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2006-04-29 20:13:27 +0000
committerMarcel Molina <marcel@vernix.org>2006-04-29 20:13:27 +0000
commit995167ec2eced73f44d4f961349dbbee6b297210 (patch)
treecd03978ee19fc2dfc57e534761ecfc4468d31adb /activesupport/lib
parent61864909628f5ac2f20d3337e0274dab016ac7c5 (diff)
downloadrails-995167ec2eced73f44d4f961349dbbee6b297210.tar.gz
rails-995167ec2eced73f44d4f961349dbbee6b297210.tar.bz2
rails-995167ec2eced73f44d4f961349dbbee6b297210.zip
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
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/module/aliasing.rb7
1 files changed, 5 insertions, 2 deletions
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