Method: Mongo::Cursor#each
- Defined in:
- lib/mongo/cursor.rb
#each { ... } ⇒ Object
Iterate over each document in this cursor, yielding it to the given block.
Iterating over an entire cursor will close it.
226 227 228 229 230 231 232 233 |
# File 'lib/mongo/cursor.rb', line 226 def each #num_returned = 0 #while has_next? && (@limit <= 0 || num_returned < @limit) while doc = next_document yield doc #next_document #num_returned += 1 end end |