Hi all, As a learning exercise, I've started working on a sort of clojure clone of ActiveRecord (from Rails). You can see it here: http://github.com/duelinmarkers/clj-record/tree/master
The model used in the tests is defined in files here: http://github.com/duelinmarkers/clj-record/tree/master/clj_record/test/model And the tests most worth reading are: http://github.com/duelinmarkers/clj-record/tree/master/clj_record/test/core-test.clj http://github.com/duelinmarkers/clj-record/tree/master/clj_record/test/associations-test.clj I'd be interested in any feedback about issues you see, idioms I could be using that I'm not, suggestions on testing approach, or other comments or questions. One style question I'm particularly interested in is what people think the model setup should look like. Currently I've got it implemented to allow a minimum of punctuation: (cljrec/init-model (has-many products)) But is it bad form to use the fact that macros don't evaluate arguments to allow all those naked symbols? For consistency with ns it seems it would be preferable to make has-many a keyword: (cljrec/init-model (:has-many products)) (There actually is a has-many method that gets invoked by init-model, but that's an implementation detail.) My gut says the least confusing approach for a user would be this. (cljrec/init-model (:has-many :products)) ... but something seems weird to me about both :has-many and :products being keywords, where :has-many is a magic keyword and :products is a name being introduced. (Note it doesn't define a var called 'products but does create 'find-products and 'destroy-products functions.) Note that I'm using clojure.contrib.sql and not worrying about the constantly opening and closing connections. Obviously I'd need some way of wrapping a single db transaction around a bunch of expressions to make this a generally useful library. But that's not the point right now. Thanks. -hume. -- http://elhumidor.blogspot.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---