Created
April 17, 2015 09:42
-
-
Save donbonifacio/16b907f772e170ea58fc to your computer and use it in GitHub Desktop.
Gateway resolver
This file contains hidden or 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 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