aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector/inflections.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-02-24 15:06:17 -0800
committerXavier Noria <fxn@hashref.com>2012-02-24 15:06:17 -0800
commit31ceb5e67b164eb98cddd5aef0bc87dad606a6bf (patch)
treeaab6e9397a81a3bc0948e22cf8a154a0e216b361 /activesupport/lib/active_support/inflector/inflections.rb
parent004326ecea6ad267b03cf7737b489e6622301985 (diff)
downloadrails-31ceb5e67b164eb98cddd5aef0bc87dad606a6bf.tar.gz
rails-31ceb5e67b164eb98cddd5aef0bc87dad606a6bf.tar.bz2
rails-31ceb5e67b164eb98cddd5aef0bc87dad606a6bf.zip
decouples the implementation of the inflector from its test suite
Trying alternative implementations of the inflections is hard because the suite is coupled with the current one, setting ivars by hand etc. This commit relies on initialize_dup, as long as you maintain that one you can tweak the implementation.
Diffstat (limited to 'activesupport/lib/active_support/inflector/inflections.rb')
-rw-r--r--activesupport/lib/active_support/inflector/inflections.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/inflector/inflections.rb b/activesupport/lib/active_support/inflector/inflections.rb
index 8cd96fe2d1..13b23d627a 100644
--- a/activesupport/lib/active_support/inflector/inflections.rb
+++ b/activesupport/lib/active_support/inflector/inflections.rb
@@ -28,6 +28,13 @@ module ActiveSupport
@plurals, @singulars, @uncountables, @humans, @acronyms, @acronym_regex = [], [], [], [], {}, /(?=a)b/
end
+ # Private, for the test suite.
+ def initialize_dup(orig)
+ %w(plurals singulars uncountables humans acronyms acronym_regex).each do |scope|
+ instance_variable_set("@#{scope}", orig.send(scope).dup)
+ end
+ end
+
# Specifies a new acronym. An acronym must be specified as it will appear in a camelized string. An underscore
# string that contains the acronym will retain the acronym when passed to `camelize`, `humanize`, or `titleize`.
# A camelized string that contains the acronym will maintain the acronym when titleized or humanized, and will