Calliing .transform_keys
on a hash to …well… transform the keys of the hash
some_hash = {
key_1: "value 1",
key_2: "value 2"
}
some_hash.transform_keys {|key| key.to_s.upcase}
# Outputs
# {"KEY_1"=>"value 1", "KEY_2"=>"value 2"}
There is also .deep_transform_keys
which will apply the same block against nested hashes. This does not apply to arrays.