Try to write the code as declarative as you possible can (that usually means in 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, since I don't like Hash[...]
and prefer Enumerable#mash, I'd really write preferences.mash { |k, v| [k.to_sym, special_values.fetch(v, v)] }
.