addywaddy

addywaddy

addywaddy  //  

Jan 22 / 12:15pm

Introducing CouchSurfer

I recently switched over from dm-couchdb-adapter to couchrest for a little project I've been working on for far too long now. One of the reasons was to force me to think more about CouchDB views and avoid accidentally using temporary views.

CouchRest comes with CouchRest::Model, which provides a nice ORM. I wrote a mix-in which sat in my lib/folder and implemented basic associations and validations and worked well for my needs. And left it at that. For about 2 days.

I then heard that Chris was planning on extracting CouchRest::Model out of CouchRest and setting it up as a separate project and, fancying a go at it myself while include the above mentioned features, I set about building my very first gem. The first step was to implement the model, which involved copious amounts of copy and paste (although I made the task a bit harder for myself by rewriting it as a mix-in). I then added associations, validations (using the Validatable gem plus writing a validates_uniqueness_of method) also as mix-ins. The fruits of my labour can be found here:
 
 http://github.com/addywaddy/couchsurfer
 
Check out the README for a basic introduction to what it can do. I must say, although I've been programming Rails/Ruby/Merb for a while now, I've never had much of a use-case for meta-programming so it's been great fun getting from how I wanted the DSL to look to implementing it so that it actually worked.

Now, back to that little project … :)

2 comments

Jul 22, 2009
Ed Ruder said...
Your link to couchsurfer on github has a typo.
Jul 23, 2009
addywaddy said...
corrected - thanks Ed!

Leave a comment...

 
Got an account with one of these? Login here, or just enter your comment below.
Posterous-login    Connect    twitter