Commit 06dfa79 1 parent 8dab89b commit 06dfa79 Copy full SHA for 06dfa79
File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 7
7
[clojure.string :as str]
8
8
[weavejester.dependency :as dep]))
9
9
10
+ (def ^:private registry (atom {}))
11
+
12
+ (defn annotate
13
+ " Annotate a namespaced keyword with a map of metadata that will be stored in a
14
+ global registry. Use [[describe]] to retrieve the keyword annotation map."
15
+ [kw metadata]
16
+ {:pre [(qualified-keyword? kw) (map? metadata)]}
17
+ (swap! registry assoc kw metadata))
18
+
19
+ (defn describe
20
+ " Return the annotation map for a namespaced keyword."
21
+ [kw]
22
+ {:pre [(qualified-keyword? kw)]}
23
+ (@registry kw))
24
+
10
25
(defprotocol RefLike
11
26
(ref-key [r] " Return the key of the reference." )
12
27
(ref-resolve [r config resolvef] " Return the resolved value." ))
Original file line number Diff line number Diff line change 73
73
(defn- init-example [v]
74
74
(str " init" v))
75
75
76
+ (deftest annotate-describe-test
77
+ (ig/annotate ::foo {:doc " A test keyword" })
78
+ (ig/annotate ::bar {:doc " Another test keyword" })
79
+ (is (= {:doc " A test keyword" } (ig/describe ::foo )))
80
+ (is (= {:doc " Another test keyword" } (ig/describe ::bar ))))
81
+
76
82
(deftest ref-test
77
83
(is (ig/ref? (ig/ref ::foo )))
78
84
(is (ig/ref? (ig/ref [::foo ::bar ])))
You can’t perform that action at this time.
0 commit comments