From 254698d325a3d64cce4aa34110fdf09930cfa0f4 Mon Sep 17 00:00:00 2001 From: oakes Date: Sun, 12 Jan 2014 04:08:06 -0500 Subject: [PATCH] Rewrite calls! so it is more reliable and requires less syntax --- src/play_clj/utils.clj | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/play_clj/utils.clj b/src/play_clj/utils.clj index 2558457..3df8394 100644 --- a/src/play_clj/utils.clj +++ b/src/play_clj/utils.clj @@ -56,18 +56,22 @@ [a] (Array. true (into-array a) 1 (count a))) -(defn create-method-call - [[k v]] - (flatten (list (key->method k) (try (eval v) - (catch Exception _ v))))) - (defmacro call! [obj k & args] `(~(key->method k) ~obj ~@args)) +(defn create-method-calls + [calls args] + (let [method-name (first args) + [my-args rest-args] (split-with #(not (keyword? %)) (rest args))] + (if method-name + (create-method-calls (conj calls `(~(key->method method-name) ~@my-args)) + rest-args) + calls))) + (defmacro calls! - [obj & {:keys [] :as args}] - `(doto ~obj ~@(map create-method-call args))) + [obj & args] + `(doto ~obj ~@(create-method-calls [] args))) (defmulti create-entity class)