Skip to content

Commit

Permalink
Merge pull request rails#5208 from ysoslow/ef79b8400f064361b2dbe1ee89…
Browse files Browse the repository at this point in the history
…f42d2adc103a3c

Inject in constantize
  • Loading branch information
tenderlove committed Feb 28, 2012
2 parents 5bbd2d3 + ef79b84 commit f07a957
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions activesupport/lib/active_support/inflector/methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f07a957

Please sign in to comment.