Line data Source code
1 4 : (ns matchscore.domain.class.entity
2 : (:require
3 :
4 : [schemas.domain.classes- :as class-schemas]))
5 :
6 :
7 16 : (def updatable-fields [:name :max-players])
8 :
9 :
10 4 : (defn make-class
11 : "Creates a validated Class map."
12 : [data]
13 12 : (class-schemas/make-class-record data))
14 :
15 :
16 4 : (defn has-changes?
17 : "Returns true if merging updates into existing would produce a different result."
18 : [existing updates]
19 2 : (not=
20 4 : (select-keys existing updatable-fields)
21 7 : (select-keys (merge existing updates) updatable-fields)))
22 :
23 :
24 4 : (defn merge-updates
25 : "Merges updatable fields from updates into existing class."
26 : [existing updates]
27 7 : (merge existing (select-keys updates updatable-fields)))
|