Skip to content
This repository
Browse code

we already have the module objects, do not constantize

I have also chosen a variable name that matches the
parameter in the definition of load_missing_constant.
  • Loading branch information...
commit 2ed325a3e90fc17c2d52a26bd1799b5f4e4bdf88 1 parent 021cb85
Xavier Noria fxn authored

Showing 1 changed file with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. +6 2 activesupport/lib/active_support/dependencies.rb
8 activesupport/lib/active_support/dependencies.rb
@@ -169,8 +169,12 @@ def self.exclude_from(base)
169 169 end
170 170
171 171 def const_missing(const_name)
172   - namespace = name.presence || "Object"
173   - Dependencies.load_missing_constant(Inflector.constantize(namespace), const_name)
  172 + # The interpreter does not pass nesting information, and in the
  173 + # case of anonymous modules we cannot even make the trade-off of
  174 + # assuming their name reflects the nesting. Resort to Object as
  175 + # the only meaningful guess we can make.
  176 + from_mod = anonymous? ? ::Object : self
  177 + Dependencies.load_missing_constant(from_mod, const_name)
174 178 end
175 179
176 180 def unloadable(const_desc = self)

0 comments on commit 2ed325a

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