public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Make constantize look into ancestors

[#410 state:resolved]

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

Conflicts:

  activesupport/lib/active_support/inflector.rb
jeremy (author)
Mon Dec 15 11:04:43 -0800 2008
commit  eca79e6bf052041c018c7ba08750238f8b2ecb7a
tree    2de81c9a86d46ebca622eba0671d101693fbbd7a
parent  d0a3dbf5aa3d9105364556c9ec5847ab3ecacaf8
...
281
282
283
284
285
286
 
287
288
289
...
281
282
283
 
 
 
284
285
286
287
0
@@ -281,9 +281,7 @@ module ActiveSupport
0
       names.shift if names.empty? || names.first.empty?
0
 
0
       constant = Object
0
-      names.each do |name|
0
-        constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
0
-      end
0
+      names.each { |name| constant = constant.const_get(name) }
0
       constant
0
     end
0
 
...
2
3
4
 
 
 
 
 
 
 
 
 
 
 
 
5
6
 
7
8
9
...
121
122
123
124
 
 
 
125
126
127
...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
134
135
136
 
137
138
139
140
141
142
0
@@ -2,8 +2,21 @@ require 'abstract_unit'
0
 require 'inflector_test_cases'
0
 
0
 module Ace
0
+  module Extension
0
+    def self.included(base)
0
+      base.extend(ClassMethods)
0
+    end
0
+
0
+    module ClassMethods
0
+      def mission_accomplished?
0
+        false
0
+      end
0
+    end
0
+  end
0
+
0
   module Base
0
     class Case
0
+      include Extension
0
     end
0
   end
0
 end
0
@@ -121,7 +134,9 @@ class InflectorTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_constantize_does_lexical_lookup
0
-    assert_raises(NameError) { ActiveSupport::Inflector.constantize("Ace::Base::InflectorTest") }
0
+    assert_equal InflectorTest, ActiveSupport::Inflector.constantize("Ace::Base::InflectorTest")
0
+    assert_nothing_raised { Ace::Base::Case::ClassMethods }
0
+    assert_nothing_raised { assert_equal Ace::Base::Case::ClassMethods, ActiveSupport::Inflector.constantize("Ace::Base::Case::ClassMethods") }
0
   end
0
 
0
   def test_ordinal

Comments