Created
April 20, 2014 09:25
-
-
Save malcolmsparks/11109616 to your computer and use it in GitHub Desktop.
Autowire dependenices in component
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 autowire-dependencies-satisfying | |
"Return a dependency map, adding dependencies between the given | |
key (of the dependant) and any components in the given system map that | |
satisfy the given protocol." | |
[dependency-map system-map dependant-key proto] | |
(merge-with merge dependency-map (normalize-dependency-map {dependant-key (vec (keep (fn [[k v]] (when (satisfies? proto v) k)) (seq system-map)))}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment