Props to Jeremy Voorhis for this cool and simple Hash maneuver.
class Hash
def rewrite mapping
inject({}) do |rewritten_hash, (original_key, value)|
rewritten_hash[mapping.fetch(original_key, original_key)] = value
rewritten_hash
end
end
end
Example usage:
h = { :human => 'squishy', :robot => 'tinny' }
h.rewrite(:human [...]