aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-02-28 12:19:07 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-02-28 12:19:07 -0800
commitf07a9578a39211d6434dfe8c2899646ca0916dab (patch)
tree8028311d557680fcd41583dfbcde4fd3383107b5
parent5bbd2d3aa805965c83b284d85efb17d97ba316b5 (diff)
parentef79b8400f064361b2dbe1ee89f42d2adc103a3c (diff)
downloadrails-f07a9578a39211d6434dfe8c2899646ca0916dab.tar.gz
rails-f07a9578a39211d6434dfe8c2899646ca0916dab.tar.bz2
rails-f07a9578a39211d6434dfe8c2899646ca0916dab.zip
Merge pull request #5208 from ysoslow/ef79b8400f064361b2dbe1ee89f42d2adc103a3c
Inject in constantize
-rw-r--r--activesupport/lib/active_support/inflector/methods.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb
index c630bd21b1..48ea5653c7 100644
--- a/activesupport/lib/active_support/inflector/methods.rb
+++ b/activesupport/lib/active_support/inflector/methods.rb
@@ -209,12 +209,10 @@ module ActiveSupport
def constantize(camel_cased_word) #:nodoc:
names = camel_cased_word.split('::')
names.shift if names.empty? || names.first.empty?
-
- constant = Object
- names.each do |name|
- constant = constant.const_get(name, false)
+
+ names.inject(Object) do |constant, name|
+ constant.const_get(name, false)
end
- constant
end
# Tries to find a constant with the name specified in the argument string: