mirror of https://github.com/rails/rails
Inflector/constantize - inject method lets us to avoid using another variable
This commit is contained in:
parent
699ba8ab52
commit
ef79b8400f
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue