Permalink
Browse files

build-handlers macro

  • Loading branch information...
1 parent 6289a6e commit 4bf1b75c9504a9146ffa57e37e167fcd88a7d5de Andrey Paramonov committed Nov 19, 2012
Showing with 11 additions and 7 deletions.
  1. +11 −7 src/dojo/handler.clj
View
@@ -6,15 +6,19 @@
(when (or ~@args)
~@body))))
-(defn- handlers []
- [(handler doc [a c]
- (format "Document:%s:%s" a c))
+(defmacro build-handlers [& body]
+ `(defn- handlers []
+ [~@body]))
- (handler note [b c]
- (format "Note:%s:%s" b c))
+(build-handlers
+ (handler doc [a c]
+ (format "Document:%s:%s" a c))
- (handler alert [a b]
- (format "Alert:%s:%s" a b))])
+ (handler note [b c]
+ (format "Note:%s:%s" b c))
+
+ (handler alert [a b]
+ (format "Alert:%s:%s" a b)))
(defn on-message [msg]
(letfn [(handle [acc h]

0 comments on commit 4bf1b75

Please sign in to comment.