Skip to content

Instantly share code, notes, and snippets.

@kuon
Created November 24, 2012 22:11
Show Gist options
  • Save kuon/4141603 to your computer and use it in GitHub Desktop.
Save kuon/4141603 to your computer and use it in GitHub Desktop.
hash = {}
a.resource_sets.each do |set|
r = set.resource
hash[set.key] = {
:id => r.id,
:url => r.url
}
end
hash
@seanstickle
Copy link

a.resource_sets.reduce({}) do |a, x|
a[x.key] = { id: x.resource.id, url: x.resource.url }; a
end

@canton7
Copy link

canton7 commented Nov 24, 2012

Hash[a.resource_sets.map{ |a,x| [a, { id: x.resource.id, url: x.resource.url }] }]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment