Map Hash in Ruby

0

I am loading a hash of an .yml file in the following format:

{ 'user_id' => 'id', 'profile' => { 'about_me' => 'about', 'phone' => { 'mobile' => 'mobile_phone', 'home' => 'home_phone' }}}

I want to output another hash with values pointing to the path to them.

For the above case the expected output would be:

{'id' => 'user_id', 'about' => {'profile' => 'about_me'}, 'mobile_phone'  => {'profile' => {'phone' => 'mobile'} }, home_phone => => {'profile' => {'phone' => 'home'}}

I think I would get this result using a recursive function, but I could not get that result.

    
asked by anonymous 11.02.2018 / 18:04

0 answers