Skip to content

Instantly share code, notes, and snippets.

@rbirnie
Created January 14, 2014 23:58
Show Gist options
  • Save rbirnie/510312edf3d4f2d90361 to your computer and use it in GitHub Desktop.
Save rbirnie/510312edf3d4f2d90361 to your computer and use it in GitHub Desktop.
1.9.3-p484 :082 > a = [{"persistent"=>true,"format_type"=>"raw","name"=>"fog-492279386986572","capacity"=>"10G","allocation"=>"0G","id"=>"","pool_name"=>"VolGroup00"}]
=> [{"persistent"=>true, "format_type"=>"raw", "name"=>"fog-492279386986572", "capacity"=>"10G", "allocation"=>"0G", "id"=>"", "pool_name"=>"VolGroup00"}]
1.9.3-p484 :083 > a.map! do |volume|
1.9.3-p484 :084 > if volume.instance_of?(Hash) && volume[:id].present?
1.9.3-p484 :085?> volume
1.9.3-p484 :086?> elsif volume.instance_of?(Hash)
1.9.3-p484 :087?> volume.reject! { |k, v| k == :id }
1.9.3-p484 :088?> end
1.9.3-p484 :089?> end
=> [nil]
Should be:
=> [{"persistent"=>true, "format_type"=>"raw", "name"=>"fog-492279386986572", "capacity"=>"10G", "allocation"=>"0G", "pool_name"=>"VolGroup00"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment