aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector/inflections.rb
diff options
context:
space:
mode:
authorRobin Dupret <robin.dupret@gmail.com>2014-03-02 18:30:54 +0100
committerRobin Dupret <robin.dupret@gmail.com>2014-06-26 14:03:56 +0200
commit643409dcb04e7ac6a6c7b09edfb9606563e9aa21 (patch)
treea4b92cf8ea1c6b83d50a8df41fdcbff52107391b /activesupport/lib/active_support/inflector/inflections.rb
parent6099b643e6388c23fab40f645544ed4dc478e763 (diff)
downloadrails-643409dcb04e7ac6a6c7b09edfb9606563e9aa21.tar.gz
rails-643409dcb04e7ac6a6c7b09edfb9606563e9aa21.tar.bz2
rails-643409dcb04e7ac6a6c7b09edfb9606563e9aa21.zip
Make the apply_inflections method case-sensitive
Since d3071db1, the apply_inflections method check if the downcased version of a string is contained inside the "whitelist" of uncountable words. However, if the word is composed of capital letters, it won't be matched in the list while it should. We can't simply revert to the previous behavior as there is a performance concern (benchmarked over /usr/share/dict/words): Before d3071db1 135.610000 0.290000 135.900000 (137.807081) Since d3071db1 22.170000 0.020000 22.190000 ( 22.530005) With the patch 22.060000 0.020000 22.080000 ( 22.125771) Benchmarked with http://git.io/aFnWig This way, the solution is to put the down-case version of words inside the @uncountables array.
Diffstat (limited to 'activesupport/lib/active_support/inflector/inflections.rb')
-rw-r--r--activesupport/lib/active_support/inflector/inflections.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/inflector/inflections.rb b/activesupport/lib/active_support/inflector/inflections.rb
index eda0edff28..97401ccec7 100644
--- a/activesupport/lib/active_support/inflector/inflections.rb
+++ b/activesupport/lib/active_support/inflector/inflections.rb
@@ -160,7 +160,7 @@ module ActiveSupport
# uncountable 'money', 'information'
# uncountable %w( money information rice )
def uncountable(*words)
- (@uncountables << words).flatten!
+ @uncountables += words.flatten.map(&:downcase)
end
# Specifies a humanized form of a string by a regular expression rule or