minor: doc

This commit is contained in:
Mike Dirolf 2009-08-21 11:21:33 -04:00
parent 28e795e9e2
commit 6a43aaa94f
1 changed files with 11 additions and 5 deletions

View File

@ -1,4 +1,3 @@
# --
# Copyright (C) 2008-2009 10gen Inc. # Copyright (C) 2008-2009 10gen Inc.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -12,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# ++
require 'mongo/message' require 'mongo/message'
require 'mongo/util/byte_buffer' require 'mongo/util/byte_buffer'
@ -29,6 +27,9 @@ module Mongo
attr_reader :db, :collection, :query attr_reader :db, :collection, :query
# Create a new cursor.
#
# Should not be called directly by application developers.
def initialize(db, collection, query, admin=false) def initialize(db, collection, query, admin=false)
@db, @collection, @query, @admin = db, collection, query, admin @db, @collection, @query, @admin = db, collection, query, admin
@num_to_return = @query.number_to_return || 0 @num_to_return = @query.number_to_return || 0
@ -39,8 +40,6 @@ module Mongo
@rows = nil @rows = nil
end end
def closed?; @closed; end
# Return the next object or nil if there are no more. Raises an error # Return the next object or nil if there are no more. Raises an error
# if necessary. # if necessary.
def next_object def next_object
@ -125,7 +124,7 @@ module Mongo
@rows @rows
end end
# Returns an explain plan record. # Returns an explain plan record for this cursor.
def explain def explain
old_val = @query.explain old_val = @query.explain
@query.explain = true @query.explain = true
@ -143,6 +142,10 @@ module Mongo
# Note: if a cursor is read until exhausted (read until OP_QUERY or # Note: if a cursor is read until exhausted (read until OP_QUERY or
# OP_GETMORE returns zero for the cursor id), there is no need to # OP_GETMORE returns zero for the cursor id), there is no need to
# close it by calling this method. # close it by calling this method.
#
# Collection#find takes an optional block argument which can be used to
# ensure that your cursors get closed. See the documentation for
# Collection#find for details.
def close def close
@db.send_to_db(KillCursorsMessage.new(@cursor_id)) if @cursor_id @db.send_to_db(KillCursorsMessage.new(@cursor_id)) if @cursor_id
@cache = [] @cache = []
@ -150,6 +153,9 @@ module Mongo
@closed = true @closed = true
end end
# Returns true if this cursor is closed, false otherwise.
def closed?; @closed; end
private private
def read_all def read_all