Code should be as declarative as possible (that usually means in functional styleusually by using functional style):
def transform
special_values = {"1" => true, "0" => false}
Hash[preferences.map { |k, v| [k.to_sym, special_values.fetch(v, v)] }]
end
However, Hash[...]
is very ugly and I prefer a more OOP approach with Enumerable#mash, so I'd really write preferences.mash { |k, v| [k.to_sym, special_values.fetch(v, v)] }
.