Skip to content

Commit

Permalink
Allow performing query with no timeout.
Browse files Browse the repository at this point in the history
Fixes #33.
  • Loading branch information
jnunemaker committed Jul 3, 2013
1 parent 0e257fb commit c75a99f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/plucky/query.rb
Expand Up @@ -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={})
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c75a99f

Please sign in to comment.