jgaskins / perpetuity

Persistence gem for Ruby objects using the Data Mapper pattern
http://jgaskins.org/blog/2012/04/20/data-mapper-vs-active-record/
MIT License
250 stars 14 forks source link

Fix IdentityMap to return the same instance of the passed-in object #40

Closed jgaskins closed 10 years ago

jgaskins commented 10 years ago

Originally, this is how Perpetuity::IdentityMap worked, but then I began using it for dirty tracking, which was the wrong choice because it meant it has to duplicate the object.

An Identity Map is meant to return the same object instance to eliminate the effect of aliasing (updating two different instances of the same object).

jgaskins commented 10 years ago

This will be a relatively easy fix (just revert the commit that caused IdentityMap to duplicate objects), but it means that dirty tracking needs to be implemented in another way.

jgaskins commented 10 years ago

Fixed in 6e157f0047877d1699b37259396fedda8922211b