How to accept or transform a Hash with dynamic keys?

I’m wanting to accept a Hash with dynamic String keys and String values. In one case I want to accept passing in additional default HTTP Headers to send when making HTTP requests, in another I’m accepting a mapping of host-names to other host-names. However, it appears that dynamic-keys are not yet supported. The workaround appears to be defining an array(:hash), however the library that I am passing the params down to expects a Hash{String => String}. So I’m wondering what is the correct way to accept such data via an HTML form, validate it, or possibly do some additional transformation from an Array of Hashes, or Array of [key,value] Arrays, into a Hash{String => String} Hash?

1 Like