Skip to content

Instantly share code, notes, and snippets.

@joelkuiper
Last active August 29, 2015 14:01
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 joelkuiper/38ff5b7cadc1b18339cd to your computer and use it in GitHub Desktop.
Save joelkuiper/38ff5b7cadc1b18339cd to your computer and use it in GitHub Desktop.
(def get-var
(memoize
(fn [ns sym]
(let [path (str (s/replace ns "." "/") "/" sym ".clj")
f (io/as-file (io/resource path))]
(when (not (nil? f))
(load-string (slurp f))
(when-let [s (find-var (symbol (str ns "/" sym)))]
(var-get s)))))))
;; Used as to get a topology var defined in the file resources/topologies/<name>
(defn get-topology
[name]
(get-var (str "topologies." name) "topology"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment