Skip to content
This repository
Browse code

Equate Kernel.const_missing with Object.const_missing. Fixes #5988.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5023 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 1d554b84f8b669a2be281845a3989b8d0c40b359 1 parent bd09d9a
Nicholas Seckar authored September 05, 2006
2  activesupport/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Equate Kernel.const_missing with Object.const_missing. Fixes #5988. [Nicholas Seckar]
  4
+
3 5
 * Add ApplicationController special case to Dependencies. [Nicholas Seckar]
4 6
 
5 7
 * Don't pad remaining places with in_groups_of if specified padding value is false. [Marcel Molina Jr.]
9  activesupport/lib/active_support/dependencies.rb
@@ -206,6 +206,15 @@ def qualified_name_for(mod, name)
206 206
   # using const_missing.
207 207
   def load_missing_constant(from_mod, const_name)
208 208
     log_call from_mod, const_name
  209
+    if from_mod == Kernel
  210
+      if ::Object.const_defined?(const_name)
  211
+        log "Returning Object::#{const_name} for Kernel::#{const_name}"
  212
+        return ::Object.const_get(const_name)
  213
+      else
  214
+        log "Substituting Object for Kernel"
  215
+        from_mod = Object
  216
+      end
  217
+    end
209 218
     
210 219
     # If we have an anonymous module, all we can do is attempt to load from Object.
211 220
     from_mod = Object if from_mod.name.empty?
8  activesupport/test/dependencies_test.rb
@@ -420,4 +420,12 @@ def test_application_should_special_case_application_controller
420 420
     end
421 421
   end
422 422
   
  423
+  def test_const_missing_on_kernel_should_fallback_to_object
  424
+    with_loading 'autoloading_fixtures' do
  425
+      kls = Kernel::E
  426
+      assert_equal "E", kls.name
  427
+      assert_equal kls.object_id, Kernel::E.object_id
  428
+    end
  429
+  end
  430
+  
423 431
 end

0 notes on commit 1d554b8

Please sign in to comment.
Something went wrong with that request. Please try again.