Class Mongoid::Cursor
In: lib/mongoid/cursor.rb
Parent: Object

Mongoid wrapper of the Ruby Driver cursor.

Methods

each   new   next_document   to_a  

Included Modules

Mongoid::Collections::Retry Enumerable

Constants

OPERATIONS = [ :close, :closed?, :count, :explain, :fields, :full_collection_name, :hint, :limit, :order, :query_options_hash, :query_opts, :selector, :skip, :snapshot, :sort, :timeout   Operations on the Mongo::Cursor object that will not get overriden by the Mongoid::Cursor are defined here.

Attributes

collection  [R] 
cursor  [R] 
klass  [R] 

Public Class methods

Create the new +Mongoid::Cursor+.

@example Instantiate the cursor.

  Mongoid::Cursor.new(Person, cursor)

@param [ Class ] klass The class associated with the cursor. @param [ Collection ] collection The Mongoid::Collection instance. @param [ Mongo::Cursor ] cursor The Mongo::Cursor to be proxied.

Public Instance methods

Iterate over each document in the cursor and yield to it.

@example Iterate over the cursor.

  cursor.each { |doc| p doc.title }

Return the next document in the cursor. Will instantiate a new Mongoid document with the attributes.

@example Get the next document.

  cursor.next_document

@return [ Document ] The next document in the cursor.

Returns an array of all the documents in the cursor.

@example Get the cursor as an array.

  cursor.to_a

@return [ Array<Document> ] An array of documents.

[Validate]