From 1d0deb90a251245965918b495b8cac0d0793b466 Mon Sep 17 00:00:00 2001 From: Nicolas Buduroi Date: Thu, 21 Apr 2011 00:08:45 -0400 Subject: [PATCH] Modified defaction to expand into a combination of a macro calling a function so that the function receive the form used to call the macro. --- src/lobos/core.clj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lobos/core.clj b/src/lobos/core.clj index 740f979..d90342b 100644 --- a/src/lobos/core.clj +++ b/src/lobos/core.clj @@ -136,10 +136,11 @@ {:arglists '([name doc-string? attr-map? [params*] & body])} [name & args] (let [params (seq (first (filter vector? args))) + name* (symbol (str name \*)) [name args] (name-with-attributes name args) [params* & body] args] `(do - (defn ~name [& params#] + (defn ~name* [self# & params#] (let [[cnx-or-schema# params#] (optional #(or (schema/schema? %) (connection? %)) params#) @@ -155,6 +156,8 @@ (execute (do ~@body) ~'db-spec))) + (defmacro ~name [~'& args#] + `(~~name* (quote ~~'&form) ~@args#)) (.setMeta #'~name (merge (.meta #'~name) {:arglists '(~(vec (conj params 'cnx-or-schema?)))})))))