heroku/databasedotcom — pull request #75 by bradrobertson (2012-03-28 21:36:12+00:00)
Title: Don't use the objects in the global namespace by default when fetching constants

It's quite common to have a `Contact` of `Account` class defined in the global namespace of an application.

By default the `find_or_materialize` will use `const_get` which will return any constant reference going up the ancestry chain. This should be mitigated by passing `false` into `const_get`, otherwise, one's globally defined constant (ie. a `Contact` model in a Rails Application)

Unfortunately, even by passing `false` to `const_get`, we were still seeing constant references from up the ancestry chain (I think due to constant reloading in rails). That is why I added the `const_defined?` check to the line where `const_get` is being called, to make sure that if the constant is not defined explicitly in the module namespace, nil is in fact returned.