Skip to content

Commit

Permalink
Equate Kernel.const_missing with Object.const_missing. Fixes #5988.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5023 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
seckar committed Sep 5, 2006
1 parent bd09d9a commit 1d554b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions activesupport/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*SVN*

* Equate Kernel.const_missing with Object.const_missing. Fixes #5988. [Nicholas Seckar]

* Add ApplicationController special case to Dependencies. [Nicholas Seckar]

* Don't pad remaining places with in_groups_of if specified padding value is false. [Marcel Molina Jr.]
Expand Down
9 changes: 9 additions & 0 deletions activesupport/lib/active_support/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ def qualified_name_for(mod, name)
# using const_missing.
def load_missing_constant(from_mod, const_name)
log_call from_mod, const_name
if from_mod == Kernel
if ::Object.const_defined?(const_name)
log "Returning Object::#{const_name} for Kernel::#{const_name}"
return ::Object.const_get(const_name)
else
log "Substituting Object for Kernel"
from_mod = Object
end
end

# If we have an anonymous module, all we can do is attempt to load from Object.
from_mod = Object if from_mod.name.empty?
Expand Down
8 changes: 8 additions & 0 deletions activesupport/test/dependencies_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,4 +420,12 @@ def test_application_should_special_case_application_controller
end
end

def test_const_missing_on_kernel_should_fallback_to_object
with_loading 'autoloading_fixtures' do
kls = Kernel::E
assert_equal "E", kls.name
assert_equal kls.object_id, Kernel::E.object_id
end
end

end

0 comments on commit 1d554b8

Please sign in to comment.