|
|
|
|
|
by pmapcat
1654 days ago
|
|
That is the use case that we have to work with quite often.
In the end, we use something along the lines of (update-fn (fn [{:keys [address]}
:as customer]
(if address (update customer :address clojure.string/capitalize) customer))
customers)
which pattern matches on some `object` (map) and does processing. We find it less fragile than specifying explicit path to an element. It can also work in a polymorphic fashion. On the other hand, there is a risk of a false positive (when you modify address that you shouldn't). But you can mitigate that risk by using additional checks (in case of a customer, you can check for additional set of fields that are specific for that object(map)
edit:formatting |
|