Rewrite calls! so it is more reliable and requires less syntax
This commit is contained in:
@@ -56,18 +56,22 @@
|
|||||||
[a]
|
[a]
|
||||||
(Array. true (into-array a) 1 (count 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!
|
(defmacro call!
|
||||||
[obj k & args]
|
[obj k & args]
|
||||||
`(~(key->method k) ~obj ~@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!
|
(defmacro calls!
|
||||||
[obj & {:keys [] :as args}]
|
[obj & args]
|
||||||
`(doto ~obj ~@(map create-method-call args)))
|
`(doto ~obj ~@(create-method-calls [] args)))
|
||||||
|
|
||||||
(defmulti create-entity class)
|
(defmulti create-entity class)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user