mongoid/mongoid — pull request #2850 by nullstyle (2013-02-20 18:19:29+00:00)
Title: Add Factory#from_map_or_db for identity map use on criteria based queries

This pull request adds Factory.from_map_or_db, which will load previously instantiated documents from the identity map before instantiating a new document for a given id. In addition, this pull request changes criteria-based queries and relations to use this new method instead of Factory.from_db. This allows for statements like this to be true:

```ruby
Person.find("1").object_id == Person.where(id:"1").first.object_id
```

This change makes the IdentityMap semantics less complicated, IMO.