Skip to content

Instantly share code, notes, and snippets.

@malcolmsparks
Created April 20, 2014 09:25
Show Gist options
  • Save malcolmsparks/11109616 to your computer and use it in GitHub Desktop.
Save malcolmsparks/11109616 to your computer and use it in GitHub Desktop.
Autowire dependenices in component
(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