Skip to content

Commit f07a957

Browse files
committed
Merge pull request rails#5208 from ysoslow/ef79b8400f064361b2dbe1ee89f42d2adc103a3c
Inject in constantize
2 parents 5bbd2d3 + ef79b84 commit f07a957

File tree

1 file changed

+3
-5
lines changed
  • activesupport/lib/active_support/inflector

1 file changed

+3
-5
lines changed

activesupport/lib/active_support/inflector/methods.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,10 @@ def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
209209
def constantize(camel_cased_word) #:nodoc:
210210
names = camel_cased_word.split('::')
211211
names.shift if names.empty? || names.first.empty?
212-
213-
constant = Object
214-
names.each do |name|
215-
constant = constant.const_get(name, false)
212+
213+
names.inject(Object) do |constant, name|
214+
constant.const_get(name, false)
216215
end
217-
constant
218216
end
219217

220218
# Tries to find a constant with the name specified in the argument string:

0 commit comments

Comments
 (0)