Permalink
Browse files

Replaced -handler functions with anonymous ones

  • Loading branch information...
Andrey Paramonov
Andrey Paramonov committed Nov 19, 2012
1 parent c0b0032 commit 6289a6e169463855f3da67ea48328938d20ebade
Showing with 8 additions and 10 deletions.
  1. +8 −10 src/dojo/handler.clj
View
@@ -1,22 +1,20 @@
(ns dojo.handler)
(defmacro handler [name args & body]
- `(defn- ~(symbol (str name "-handler")) [~'msg]
+ `(fn [~'msg]
(let [~@(interleave args (map (fn [x] `(get ~'msg ~(keyword x))) args))]
(when (or ~@args)
~@body))))
-(handler doc [a c]
- (format "Document:%s:%s" a c))
-
-(handler note [b c]
- (format "Note:%s:%s" b c))
+(defn- 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))
-(defn- handlers []
- [doc-handler note-handler alert-handler])
+ (handler alert [a b]
+ (format "Alert:%s:%s" a b))])
(defn on-message [msg]
(letfn [(handle [acc h]

0 comments on commit 6289a6e

Please sign in to comment.