diff options
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/aliasing.rb | 7 |
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 |