Merge an array of hashes in Ruby depending upon a key-value pair : I have an array of hashes with fixed key-value pair as follows:

    [
      {'abc_id'=>'1234', 'def_id'=>[]},
      {'abc_id'=>'5678', 'def_id'=>['11', '22']},
      {'abc_id'=>'1234', 'def_id'=>['33', '44']},
      {'abc_id'=>'5678', 'def_id'=>['55', '66']}
    ]

Here, I'm trying to identify multiple matches of a single key-value pair and combine multiple hashes into one hash.

As per above example, we have two matching pairs with same value for 'abc_id' key as follows:

    {'abc_id'=>'1234', 'def_id'=>[]} & {'abc_id'=>'1234', 'def_id'=>['33', '44']}

and

    {'abc_id'=>'5678', 'def_id'=>['11', '22']} & {'abc_id'=>'5678', 'def_id'=>['55', '66']}

I'm expecting multiple hashes with same key-value pairs to be merged into one individual hash as follows:

For first pair it should be:

    {'abc_id'=>'1234', 'def_id'=>['33', '44']}

and

for second pair it should be:

    {'abc_id'=>'5678', 'def_id'=>['11', '22', '55', '66']}