diff options
author | Xavier Noria <fxn@hashref.com> | 2012-02-12 16:59:51 -0800 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2012-02-12 16:59:51 -0800 |
commit | 6bd7023e2feec50472f10093340e13a2b23ebde1 (patch) | |
tree | 87304734039ffd7fc29902e5bc377dfdb4275a7a /activesupport/lib | |
parent | 5cff94fd851f23265b525fe9ce5489c0b28c771c (diff) | |
download | rails-6bd7023e2feec50472f10093340e13a2b23ebde1.tar.gz rails-6bd7023e2feec50472f10093340e13a2b23ebde1.tar.bz2 rails-6bd7023e2feec50472f10093340e13a2b23ebde1.zip |
prefer tr to gsub for replacing characters
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/inflector/methods.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index ddd2aca31d..c630bd21b1 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -94,7 +94,7 @@ module ActiveSupport result = lower_case_and_underscored_word.to_s.dup inflections.humans.each { |(rule, replacement)| break if result.sub!(rule, replacement) } result.gsub!(/_id$/, "") - result.gsub!(/_/, ' ') + result.tr!('_', ' ') result.gsub(/([a-z\d]*)/i) { |match| "#{inflections.acronyms[match] || match.downcase}" }.gsub(/^\w/) { $&.upcase } @@ -146,7 +146,7 @@ module ActiveSupport # Example: # "puni_puni" # => "puni-puni" def dasherize(underscored_word) - underscored_word.gsub(/_/, '-') + underscored_word.tr('_', '-') end # Removes the module part from the expression in the string: |