On Mon, Dec 29, 2008 at 7:15 PM, Brian Doyle <brianpdo...@gmail.com> wrote:
> I noticed that in the init-model macro you are creating a 'defn table []
> ...' function in the
> model namespace and was wondering why you didn't just make it a def instead,
> since
> it doesn't take any args?

That didn't occur to me. I do like the idea of all the functionality
being available directly on clj-record.core with model name as a first
argument in addition to being defined in the model namespace, so I
guess that's one reason. But the inference of table name from model
name should only be the default, so maybe it would be better to just
def it there and let clj-record.core look it up there if needed,
somewhat as you recommended doing for callbacks...

> I have an idea for you with the callbacks like, before-create, after-create,
> etc.  In the
> all-models-metadata in the core.clj you could store the namespace in the
> hash
> associated with the model-name on setup.   Then in the create function
> defined in
> the core.clj you could call the before-create function defined in the model
> something
> like:
>
> (let-if [bc ('before-create (ns-publics <model-namespace>)] (bc
> attributes#))

That's interesting. It's basically the opposite of the way I did the
validation stuff, where you pass in validation functions and those get
stored away in metadata and aren't directly accessible. (Here
"metadata" is not used in the clojure.org/metadata sense of the word.
I've thought about using clojure metadata to store model info, but I
don't know what symbol or collection I'd attach it to.) I think I
prefer the validation approach, because those functions have a certain
job to do and shouldn't be sitting there cluttering the model
namespace. (On the other hand, it is awfully convenient to be able to
test those functions directly.)

Thanks again for looking. If you or anyone else has further comments,
I'd like to hear them.
git clone git://github.com/duelinmarkers/clj-record.git

-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
-~----------~----~----~----~------~----~------~--~---

Reply via email to