File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change 1919 (into (pop queue) tag-parents)))
2020 (distinct acc))))
2121
22+ (defn- method [registry tag initial]
23+ (let [tags (reversed-me-and-ancestors tag)]
24+ (->> tags
25+ (map registry)
26+ (remove nil?)
27+ (reduce (fn [acc decorator]
28+ (fn [obj & args]
29+ (apply decorator acc obj args)))
30+ initial))))
31+
2232(defn multi [dispatch initial]
2333 (let [iregistry (atom {})]
2434 (fn
2838 :initial initial})
2939 ([obj & args]
3040 (let [tag (apply dispatch obj args)
31- tags (reversed-me-and-ancestors tag)
32- reg @iregistry
33- f (reduce (fn [acc tag]
34- (if-some [decorator (reg tag)]
35- (fn [obj & args]
36- (apply decorator acc obj args))
37- acc))
38- initial
39- tags)]
41+ f (method @iregistry tag initial)]
4042 (apply f obj args))))))
4143
4244(defn ^{:style/indent :defn } decorate [multi tag decorator]
You can’t perform that action at this time.
0 commit comments