Skip to content

Commit

Permalink
Modified defaction to expand into a combination of a macro calling a …
Browse files Browse the repository at this point in the history
…function so that the function receive the form used to call the macro.
  • Loading branch information
budu committed Apr 21, 2011
1 parent c2c62fb commit 1d0deb9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lobos/core.clj
Expand Up @@ -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#)
Expand All @@ -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?)))})))))
Expand Down

0 comments on commit 1d0deb9

Please sign in to comment.