I am assigning a set of values based on the values of a hash.
I have to assign values to another hash key based on the value of the incoming hash key.
There are more than 10 keys in the incoming hash(so more than 10 cases).
I want to minimize the code. Is there any alternative method for this scenario to shorten the code.
@hash1.each do |h1|
case h1.mapped_field
when 'value1'
@hash2[h1.field_id] = value_1
when 'value2'
@hash2[h1.field_id] = value_2
when 'value3'
@hash2[h1.field_id] = value_3
when 'value4'
@hash2[h1.field_id] = value_4
when 'value5'
@hash2[h1.field_id] = value_5
end
end