lib/mongo/cursor.rb
# Iterate over each object, yielding it to the given block. At most
# @num_to_return records are returned (or all of them, if
# @num_to_return is 0).
#
# If #to_a has already been called then this method uses the array
# that we store internally. In that case, #each can be called multiple
# times because it re-uses that array.
#
# You can call #each after calling #to_a (multiple times even, because
# it will use the internally-stored array), but you can't call #to_a
# after calling #each unless you also called it before calling #each.
# If you try to do that, an error will be raised.
Iterate over each object, yielding it to the given block. At most
Iterate over each object yielding it to the given block . At most
def each
          if @rows              
            @rows.each { |row| yield row }
          else
            num_returned = 0
            while more? && (@num_to_return <= 0 || num_returned < @num_to_return)
              yield next_object()
              num_returned += 1
            end
            @can_call_to_a = false
          end
        end
def each if @rows @rows . each { | row | yield row } else num_returned = 0 while more? && ( @num_to_return <= 0 || num_returned < @num_to_return ) yield next_object ( ) num_returned += 1 end @can_call_to_a = false end end
Iterate over each object, yielding it to the given block.
Iterate over each object yielding it to the given block .
# Already turned into an array
num_to_return
records are returned (or all of them, if
records are returned ( or all of them if
num_to_return
None