solnic / virtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects
MIT License
3.77k stars 228 forks source link

Use ID for determining Model equality #320

Closed KaptajnKold closed 9 years ago

KaptajnKold commented 9 years ago

I find it surprising that model equality is determined by object equality. To me, it is part of the semantics of a model (or an Entity in the DDD parlance) is that equality is determined by ID. Same ID, same entity.

I propose that an attribute declared with id: true, enables this behaviour.

solnic commented 9 years ago

You can do include Equalizer.new(:id) in your models to achieve that.

KaptajnKold commented 9 years ago

Cool :)