joakimk/minimapper

Entity#persisted? should not go by id presence

Closed this issue · 2 comments

There are use cases for assigning an id to an unpersisted entity.

Currently, Minimapper entities have a persisted? that just checks for an id, which will lie if you assign an id to an unpersisted entity.

Instead, it could be the mapper's responsibility to do something like entity.persisted = true whenever you pull from the DB, save successfully etc.

See commit. How about it? Can make a pull request if you'd like.

This commit is relevant also: barsoom@cb4b63d