Skip to content

Instantly share code, notes, and snippets.

@donbonifacio
Created April 17, 2015 09:42
Show Gist options
  • Save donbonifacio/16b907f772e170ea58fc to your computer and use it in GitHub Desktop.
Save donbonifacio/16b907f772e170ea58fc to your computer and use it in GitHub Desktop.
Gateway resolver
(defn gateway-fn
"Retrieves a function given it's full name"
[gateway access method]
{:post [(not (nil? %))]}
(let [sym (symbol (str "project-namespace." (name gateway) "." (name access) "/" (name method)))]
(resolve sym)))
(defn gateway-call
"Dispatches to a function on the given provider"
[access method & args]
(let [gateway (gateway-provider)
f (gateway-fn gateway access method)]
(if args
(apply f args)
(f))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment