Created
February 28, 2012 19:25
-
-
Save mediocretes/1934554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#prone to cursor timeouts: | |
def old | |
thing.find(query, options).each do |item| | |
Enumerator.new do |y| | |
y << do_formatting_and_stuff(item) | |
end | |
end | |
end | |
#immune to cursor timeouts? the block form of find can be run with an infinite timeout cursor. | |
def new | |
Enumerator.new do |y| | |
thing.find(query, options.merge({timeout: false})).each do |cursor| | |
cursor.each do |item| | |
y << do_formatting_and_stuff(item) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment