Created
January 25, 2009 12:06
-
-
Save robertpfeiffer/51768 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
(defn before-advice [fun] | |
(fn [original] | |
(fn [& args] (apply original (apply fun args))))) | |
(defn after-advice [fun] | |
(partial comp fun)) | |
(defn around-advice [fun] | |
(fn [original] | |
(fun original))) | |
(defn weave [pointcut namespaces & advice] | |
(let [advice (apply comp (reverse advice))] | |
(doseq [join-point (filter pointcut (vals (mapcat ns-interns namespaces)))] | |
(prn join-point (meta join-point)) | |
(alter-var-root join-point advice)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment