lib/mongo/cursor.rb
# Return all of the rows (up to the +num_to_return+ value specified in
# #new) as an array. Calling this multiple times will work fine; it
# always returns the same array.
#
# Don't use this if you're expecting large amounts of data, of course.
# All of the returned rows are kept in an array stored in this object
# so it can be reused.
#
# 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.
Return all of the rows (up to the +num_to_return+ value specified in
new) as an array. Calling this multiple times will work fine; it
always returns the same array.

Don't use this if you're expecting large amounts of data, of course.
All of the returned rows are kept in an array stored in this object
so it can be reused.


Return all of the rows ( up to the + num_to_return + value specified in new ) as an array . Calling this multiple times will work fine ; it always returns the same array . Don ' t use this if you ' re expecting large amounts of data of course . All of the returned rows are kept in an array stored in this object so it can be reused .
def to_a
          return @rows if @rows
          raise "can't call Cursor#to_a after calling Cursor#each" unless @can_call_to_a
          @rows = []
          num_returned = 0
          while more? && (@num_to_return <= 0 || num_returned < @num_to_return)
            @rows << next_object()
            num_returned += 1
          end
          @rows
        end
def to_a return @rows if @rows raise "can't call Cursor#to_a after calling Cursor#each" unless @can_call_to_a @rows = [ ] num_returned = 0 while more? && ( @num_to_return <= 0 || num_returned < @num_to_return ) @rows << next_object ( ) num_returned += 1 end @rows end
Return all of the rows (up to the +num_to_return+ value specified in
new) as an array.
Return all of the rows ( up to the + num_to_return + value specified in new ) as an array .