0
@@ -330,47 +330,30 @@ module ActiveSupport
0
underscore(demodulize(class_name)) + (separate_class_name_and_id_with_underscore ? "_id" : "id")
0
- # Ruby 1.9 introduces an inherit argument for Module#const_get and
0
- # #const_defined? and changes their default behavior.
0
- if Module.method(:const_get).arity == 1
0
- # Tries to find a constant with the name specified in the argument string:
0
- # "Module".constantize # => Module
0
- # "Test::Unit".constantize # => Test::Unit
0
- # The name is assumed to be the one of a top-level constant, no matter whether
0
- # it starts with "::" or not. No lexical context is taken into account:
0
- # "C".constantize # => 'outside', same as ::C
0
- # NameError is raised when the name is not in CamelCase or the constant is
0
- def constantize(camel_cased_word)
0
- names = camel_cased_word.split('::')
0
- names.shift if names.empty? || names.first.empty?
0
- constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
0
- def constantize(camel_cased_word) #:nodoc:
0
- names = camel_cased_word.split('::')
0
- names.shift if names.empty? || names.first.empty?
0
- constant = constant.const_get(name, false) || constant.const_missing(name)
0
+ # Tries to find a constant with the name specified in the argument string:
0
+ # "Module".constantize # => Module
0
+ # "Test::Unit".constantize # => Test::Unit
0
+ # The name is assumed to be the one of a top-level constant, no matter whether
0
+ # it starts with "::" or not. No lexical context is taken into account:
0
+ # "C".constantize # => 'outside', same as ::C
0
+ # NameError is raised when the name is not in CamelCase or the constant is
0
+ def constantize(camel_cased_word)
0
+ names = camel_cased_word.split('::')
+ names.shift if names.empty? || names.first.empty?
0
+ names.each { |name| constant = constant.const_get(name) }
0
# Turns a number into an ordinal string used to denote the position in an
What’s the point of
names.shiftifnamesis empty?