1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Inflector/constantize - inject method lets us to avoid using another variable

This commit is contained in:
homa 2012-02-28 18:34:19 +01:00
parent 699ba8ab52
commit ef79b8400f

View file

@ -210,11 +210,9 @@ module ActiveSupport
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: