aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-01-28 15:52:45 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-01-28 15:52:45 +0000
commitb0ed5057e01b78f2f7e0e078c0534647b425c290 (patch)
tree5f95376c0507f8decd83b76c17de93ed8dfc48e2 /activesupport/lib/active_support/inflector.rb
parent269ad9711ddc179e72cc7da3176893a1dcca1b26 (diff)
downloadrails-b0ed5057e01b78f2f7e0e078c0534647b425c290.tar.gz
rails-b0ed5057e01b78f2f7e0e078c0534647b425c290.tar.bz2
rails-b0ed5057e01b78f2f7e0e078c0534647b425c290.zip
Full test coverage for Inflector. Closes #7228.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6075 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/inflector.rb')
-rw-r--r--activesupport/lib/active_support/inflector.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb
index 8f71b71237..084c58d389 100644
--- a/activesupport/lib/active_support/inflector.rb
+++ b/activesupport/lib/active_support/inflector.rb
@@ -243,12 +243,11 @@ module Inflector
# "Module".constantize #=> Module
# "Class".constantize #=> Class
def constantize(camel_cased_word)
- unless /^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ camel_cased_word
+ unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ camel_cased_word
raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!"
end
- camel_cased_word = "::#{camel_cased_word}" unless $1
- Object.module_eval(camel_cased_word, __FILE__, __LINE__)
+ Object.module_eval("::#{$1}", __FILE__, __LINE__)
end
# Ordinalize turns a number into an ordinal string used to denote the