Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #5208 from ysoslow/ef79b8400f064361b2dbe1ee89f42d2…

…adc103a3c

Inject in constantize
  • Loading branch information...
commit f07a9578a39211d6434dfe8c2899646ca0916dab 2 parents 5bbd2d3 + ef79b84
@tenderlove tenderlove authored
Showing with 3 additions and 5 deletions.
  1. +3 −5 activesupport/lib/active_support/inflector/methods.rb
View
8 activesupport/lib/active_support/inflector/methods.rb
@@ -209,12 +209,10 @@ def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
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:
Please sign in to comment.
Something went wrong with that request. Please try again.