Permalink
Browse files

Make constantize look into ancestors

[#410 state:resolved]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>

Conflicts:

	activesupport/lib/active_support/inflector.rb
  • Loading branch information...
1 parent d0a3dbf commit eca79e6bf052041c018c7ba08750238f8b2ecb7a @jeremy jeremy committed Dec 15, 2008
Showing with 17 additions and 4 deletions.
  1. +1 −3 activesupport/lib/active_support/inflector.rb
  2. +16 −1 activesupport/test/inflector_test.rb
@@ -281,9 +281,7 @@ def constantize(camel_cased_word)
names.shift if names.empty? || names.first.empty?
constant = Object
- names.each do |name|
- constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
- end
+ names.each { |name| constant = constant.const_get(name) }
constant
end
@@ -2,8 +2,21 @@
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
@@ -121,7 +134,9 @@ def test_constantize
end
def test_constantize_does_lexical_lookup
- assert_raises(NameError) { ActiveSupport::Inflector.constantize("Ace::Base::InflectorTest") }
+ 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") }
end
def test_ordinal

0 comments on commit eca79e6

Please sign in to comment.