Skip to content

Instantly share code, notes, and snippets.

@pauldix
Created August 27, 2009 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pauldix/176464 to your computer and use it in GitHub Desktop.
Save pauldix/176464 to your computer and use it in GitHub Desktop.
hydra = Typhoeus::Hydra.new(20) # number is the size of the easy object pool
user_request = User.find_request(1) # where 1 is the id of the user
user_request.when_complete do
@user = User.parse(user_request.response.body)
comment_requests = @user.comment_ids.map {|id| Comment.find_request(id)}
comment_requests.each do |comment_request|
comment_request.when_complete do
@user.comments << Comment.parse(comment_request.response.body)
end
hydra.queue_request(comment_request)
end
end
hydra.queue_request(user_request)
hydra.run
# now we have a user object with all the comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment