mongoid/mongoid — pull request #1381 by canavese (2011-10-27 23:50:41+00:00)
Title: Fix IdentityMap to work with inherited classes.

The IdentityMap currently stores documents by class. However, this does not work with inherited classes, as they are stored by the subclass and may be requested by the superclass name (particularly with eager loading). So I changed the IdentityMap to store by the collection name, which seems more appropriate.

Since it appears that embedded documents may also be stored in the IdentityMap, I append the class name to the collection name. Actually, it appears that the collection name is just assigned for embedded documents based on the class name, so maybe this is not appropriate. I'm not sure what's best for this case... is there even a use case for storing embedded documents in the IdentityMap?

I updated the tests and added a few to cover these new cases.

Let me know if you have any questions. This addresses the bug https://github.com/mongoid/mongoid/issues/1371

Thanks!