Skip to content

Instantly share code, notes, and snippets.

@raek
Created July 21, 2011 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raek/1098101 to your computer and use it in GitHub Desktop.
Save raek/1098101 to your computer and use it in GitHub Desktop.
(ns se.raek.kerodon.util)
(defn proxy* [class-and-interfaces ctor-args & method-fn-pairs]
(let [proxy-class (apply get-proxy-class class-and-interfaces)
proxy-object (apply construct-proxy proxy-class ctor-args)]
(doto proxy-object
(init-proxy (apply hash-map method-fn-pairs)))))
(comment ; Usage
(defn run [this]
(println "Hello, world!"))
(def r (proxy* [Runnable] []
"run" #'run))
(.run r))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment