aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorhoma <homakov@gmail.com>2012-02-28 18:34:19 +0100
committerhoma <homakov@gmail.com>2012-02-28 18:34:19 +0100
commitef79b8400f064361b2dbe1ee89f42d2adc103a3c (patch)
tree635ad0f4ec31f1d51f061878c8cc2c078b581353 /activesupport
parent699ba8ab52973bf0499643235f162734fb644ab7 (diff)
downloadrails-ef79b8400f064361b2dbe1ee89f42d2adc103a3c.tar.gz
rails-ef79b8400f064361b2dbe1ee89f42d2adc103a3c.tar.bz2
rails-ef79b8400f064361b2dbe1ee89f42d2adc103a3c.zip
Inflector/constantize - inject method lets us to avoid using another variable
Diffstat (limited to 'activesupport')
-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: