Convert object to hash ruby

Get Ruby Object (that you need to convert to hash) into one variable.

=> user = User.first

#<User id: 1, name: “Test", email: “[email protected]", updated_at: "2019-01-23 06:03:20”> 

Below method will convert your Ruby Object into hash.

=> user.as_json

{"id"=>1, "name"=>"Test", "email"=>"[email protected]", "updated_at"=>Wed, 23 Jan 2019 06:03:20 UTC +00:00}

Find below link for details about Hash:
Learn About Test cases