Skip to content

Instantly share code, notes, and snippets.

@samstokes
Created November 7, 2011 23:01
Show Gist options
  • Save samstokes/1346480 to your computer and use it in GitHub Desktop.
Save samstokes/1346480 to your computer and use it in GitHub Desktop.
DG loop combinator thinking
# Hmmm
DG::loop_until { url.present? && chunks_done < 25 }.body do
make_http_request(stuff, things, other_things).safe_callback do |blah|
blah
end
end.transform
# Yum
DG::loop_until(lambda { url.present? && chunks_done < 25 }) do
make_http_request(stuff, things, other_things).safe_callback do |blah|
blah
end
end.transform
# Yuck
DG::loop.until(lambda { url.present? && chunks_done < 25 }) do
make_http_request(stuff, things, other_things).safe_callback do |blah|
blah
end
end.transform
# Yay
DG::loop do
make_http_request(stuff, things, other_things).safe_callback do |blah|
end
end.until { url.present? && chunks_done < 25 }.transform
# Whut
expect {|x| x }.to_raise BoomError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment