Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow performing query with no timeout.

Fixes #33.
  • Loading branch information...
commit c75a99fce09c5b81927bc63a3422a71353a7092c 1 parent 0e257fb
@jnunemaker jnunemaker authored
Showing with 11 additions and 7 deletions.
  1. +11 −7 lib/plucky/query.rb
View
18 lib/plucky/query.rb
@@ -66,14 +66,18 @@ def paginate(opts={})
def find_each(opts={})
query = clone.amend(opts)
- cursor = query.cursor
if block_given?
- cursor.each { |doc| yield doc }
- cursor.rewind!
+ result = nil
+ query.cursor do |cursor|
+ result = cursor
+ cursor.each { |doc| yield doc }
+ cursor.rewind!
+ end
+ result
+ else
+ query.cursor
end
-
- cursor
end
def find_one(opts={})
@@ -228,8 +232,8 @@ def options_hash
@options.to_hash
end
- def cursor
- @collection.find(criteria_hash, options_hash)
+ def cursor(&block)
+ @collection.find(criteria_hash, options_hash, &block)
end
private
Please sign in to comment.
Something went wrong with that request. Please try again.