File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 507
507
:conflicting-index index
508
508
:expand-keys keys})))
509
509
510
+ (defn- find-in [m ks]
511
+ (if (next ks)
512
+ (-> (get-in m (butlast ks)) (find (last ks)))
513
+ (find m (first ks))))
514
+
515
+ (defn- assoc-converge [m {:keys [index value override?]}]
516
+ (if-some [[_ v] (find-in m index)]
517
+ (if (or override? (= v {})) (assoc-in m index value) m)
518
+ (assoc-in m index value)))
519
+
510
520
(defn converge
511
521
" Deep-merge the values of a map. Raises an error on conflicting keys, unless
512
522
one (and only one) of the values is tagged with the ^:override metadata."
515
525
(let [converges (mapcat converge-values m)]
516
526
(when-let [conflict (first (converge-conflicts converges))]
517
527
(throw (converge-conflict-exception m conflict)))
518
- (->> converges
519
- (sort-by :override? )
520
- (sort-by #(not= (:value %) {}))
521
- (reduce #(assoc-in %1 (:index %2 ) (:value %2 )) {}))))
528
+ (reduce assoc-converge {} converges)))
522
529
523
530
(defn expand
524
531
" Expand modules in the config map prior to initiation. The expand-key method
You can’t perform that action at this time.
0 commit comments