This post originated from an RSS feed registered with Ruby Buzz
by john hume.
Original Post: clj-record: ActiveRecord for Clojure
Feed Title: El Humidor
Feed URL: http://feeds.feedburner.com/ElHumidor
Feed Description: John D. Hume on Ruby and development with agile teams.
I've spent a chunk of the last month (and an absurd amount of the last four days) working on clj-record: an ActiveRecord-like library written in the Clojure programming language. (Clojure is a LISP dialect with badass concurrency features for the JVM.) clj-record aims to provide an idiomatic "functional" API for persistence with many of the features we've come to appreciate from ActiveRecord, currently including validation, (somewhat) convenient associations, and (some) callbacks.
(Persistence requires side-effects, so it can't really be functional, but it can be idiomatic and leverage a great deal of power from being written in a functional language.)
Here's what a model definition looks like:
(nsclj-record.test.model.manufacturer(:requireclj-record.boot))(clj-record.core/init-model(:associations(has-manyproducts))(:validation(:name"empty!" #(not(empty? %)))(:founded"must be numeric" #(or(nil? %)(not(re-find#"\D" %))))))
Coming soon:
Even more convenient associations
Even more callbacks
Serialization of data structures as attribute values