RubyFlow The Ruby and Rails community linklog

[Experimental] Repository Pattern on top of ActiveRecord

Over the past few days I’ve started experimenting with the idea of implementing the repository pattern on top of ActiveRecord (yes, it sounds scary). The motivation came after we were about to kick start a relatively large scale system. It would be great to retain the powerfulness of ActiveRecord as well as making our app easier to maintain and test. It is basically a compromise, a stop gap, if you will.

I’ve always liked the Datamapper library but unfortunately ever since the Merb/Rails merge it has stepped outside of the spotlight. Datamapper 2 is shaping up nicely but it is still a far way away. So I decided to base my experimentation on top of utilising both ActiveRecord and Virtus, the attributes component of Datamapper 2.

You can check out what I’ve been doing here: https://github.com/fredwu/datamappify

It is an experiment, and it’s still too early to see how useful and practical it’ll become, but I’d love to get some feedback from you guys!

Comments

You can use DataMapper with Rails 3 using dm-rails.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in