aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/inflector.rb')
-rw-r--r--activesupport/lib/active_support/inflector.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb
index 2e69b74c54..f91a73c7f3 100644
--- a/activesupport/lib/active_support/inflector.rb
+++ b/activesupport/lib/active_support/inflector.rb
@@ -143,9 +143,9 @@ module Inflector
def constantize(camel_cased_word)
raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!" unless
- camel_cased_word.split("::").all? { |part| /^[A-Z]\w*$/ =~ part }
+ /^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ camel_cased_word
- camel_cased_word = "::#{camel_cased_word}" unless camel_cased_word[0, 2] == '::'
+ camel_cased_word = "::#{camel_cased_word}" unless $1
Object.module_eval(camel_cased_word, __FILE__, __LINE__)
end