Permalink
Browse files

Revert "Make constantize look into ancestors"

[#410 state:open]

This reverts commit eca79e6.
  • Loading branch information...
1 parent eca79e6 commit 981314f45cbb42d1b5403ac0d984f37c82226438 @jeremy jeremy committed Dec 16, 2008
Showing with 4 additions and 17 deletions.
  1. +3 −1 activesupport/lib/active_support/inflector.rb
  2. +1 −16 activesupport/test/inflector_test.rb
View
4 activesupport/lib/active_support/inflector.rb
@@ -281,7 +281,9 @@ def constantize(camel_cased_word)
names.shift if names.empty? || names.first.empty?
constant = Object
- names.each { |name| constant = constant.const_get(name) }
+ names.each do |name|
+ constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
+ end
constant
end
View
17 activesupport/test/inflector_test.rb
@@ -2,21 +2,8 @@
require 'inflector_test_cases'
module Ace
- module Extension
- def self.included(base)
- base.extend(ClassMethods)
- end
-
- module ClassMethods
- def mission_accomplished?
- false
- end
- end
- end
-
module Base
class Case
- include Extension
end
end
end
@@ -134,9 +121,7 @@ def test_constantize
end
def test_constantize_does_lexical_lookup
- assert_equal InflectorTest, ActiveSupport::Inflector.constantize("Ace::Base::InflectorTest")
- assert_nothing_raised { Ace::Base::Case::ClassMethods }
- assert_nothing_raised { assert_equal Ace::Base::Case::ClassMethods, ActiveSupport::Inflector.constantize("Ace::Base::Case::ClassMethods") }
+ assert_raises(NameError) { ActiveSupport::Inflector.constantize("Ace::Base::InflectorTest") }
end
def test_ordinal

0 comments on commit 981314f

Please sign in to comment.