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

Use id_for to get ID for object. #37

Closed booch closed 10 years ago

booch commented 10 years ago

Fixes issue #36.

booch commented 10 years ago

Sorry. I hadn't figured out how to run the tests before I submitted this PR. :frowning: It did fix my issue in Perpetuity::Memory, but I'll have to find another way to fix that.

jgaskins commented 10 years ago

Gonna go ahead and close this unless you can see a reason to keep it open.

For Perpetuity::Memory, you could wrap the yielded value with a proxy that responds to id and delegates everything else with method_missing. If I get a chance this week, I'll drop a PR on it to show you what I mean.

booch commented 10 years ago

@jgaskins That's a good idea. I can do that myself, so if you've got other things to do, don't worry about a PR for Perpetuity::Memory. I tried running the Perpetuity specs with the memory adapter, and it's got a ways to go. :construction_worker:

jgaskins commented 10 years ago

Yeah, you'd be surprised at how quickly some of the tests will pass, though. Implementing one feature well might make 2 or 3 tests pass. At least, that's the experience I've had implementing the Postgres adapter.