Add deep_map_keys to dry-transformer HashTransformations

dry-transformer provides several built-in Hash transformation functions. Many of these operate on keys (symbolize_keys, stringify_keys, rename_keys, etc.). But only a few of them provide for deep application of these modifications to deeply-nested Hashes (only deep_symbolize_keys and deep_stringify_keys).

I’d like to introduce a new deep_map_keys function to extend the current map_keys function. This would affect the full tree of nested Hashes in the same way the other, existing deep_ methods do.

If this method were in place, it also seems like a useful choke point to combine the deep Hash traversal logic which currently exists in multiple places within HashTransformations methods. Perhaps there would be some way to use a new deep_map_keys as a common implementation detail for deep_stringify_keys and deep_symbolize_keys to remove that repetition and simplify the behaviors.

1 Like

This is a good idea, but please also check out the existing recursion functions because we may already have everything in place that’s needed. Another thing to consider is performance. I think faster functions are more important than avoiding some level of code duplication.