Created
September 9, 2013 14:44
-
-
Save ddeaguiar/6496588 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns noti.notify | |
(:require [noti.notification :as n] | |
[io.pedestal.service.log :as log])) | |
(defprotocol Notifiable | |
(notify! [_ x])) | |
(defmacro notifiable [body] | |
`(reify Notifiable | |
(notify! [_ notification] | |
(try | |
~body | |
(catch Exception e# (log/error :msg (.getMessage e#))))))) | |
(def log-notifier | |
(notifiable (spit "resources/public/notifications.txt" | |
(clojure.string/join "" [(n/text notification) "\n"]) | |
:append true))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Although possible, I think it's best to avoid magic params like 'notification' in macro usage – line 17.