@@ -277,38 +277,7 @@ def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
277
277
# NameError is raised when the name is not in CamelCase or the constant is
278
278
# unknown.
279
279
def constantize ( camel_cased_word )
280
- if camel_cased_word . blank? || !camel_cased_word . include? ( "::" )
281
- Object . const_get ( camel_cased_word )
282
- else
283
- names = camel_cased_word . split ( "::" )
284
-
285
- # Trigger a built-in NameError exception including the ill-formed constant in the message.
286
- Object . const_get ( camel_cased_word ) if names . empty?
287
-
288
- # Remove the first blank element in case of '::ClassName' notation.
289
- names . shift if names . size > 1 && names . first . empty?
290
-
291
- names . inject ( Object ) do |constant , name |
292
- if constant == Object
293
- constant . const_get ( name )
294
- else
295
- candidate = constant . const_get ( name )
296
- next candidate if constant . const_defined? ( name , false )
297
- next candidate unless Object . const_defined? ( name )
298
-
299
- # Go down the ancestors to check if it is owned directly. The check
300
- # stops when we reach Object or the end of ancestors tree.
301
- constant = constant . ancestors . inject ( constant ) do |const , ancestor |
302
- break const if ancestor == Object
303
- break ancestor if ancestor . const_defined? ( name , false )
304
- const
305
- end
306
-
307
- # owner is in Object, so raise
308
- constant . const_get ( name , false )
309
- end
310
- end
311
- end
280
+ Object . const_get ( camel_cased_word )
312
281
end
313
282
314
283
# Tries to find a constant with the name specified in the argument string.
0 commit comments