Parent

Included Modules

Class/Module Index [+]

Quicksearch

Mongoid::Cursor

Mongoid wrapper of the Ruby Driver cursor.

Constants

OPERATIONS

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 Instance Methods

each() click to toggle source

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

@example Iterate over the cursor.

cursor.each { |doc| p doc.title }
# File lib/mongoid/cursor.rb, line 46
def each
  cursor.each do |document|
    yield Mongoid::Factory.from_db(klass, document)
  end
end
next_document() click to toggle source

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.

# File lib/mongoid/cursor.rb, line 71
def next_document
  Mongoid::Factory.from_db(klass, cursor.next_document)
end
to_a() click to toggle source

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.

# File lib/mongoid/cursor.rb, line 81
def to_a
  cursor.to_a.collect { |attrs| Mongoid::Factory.from_db(klass, attrs) }
end

Public Class Methods

new(klass, collection, cursor) click to toggle source

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.

# File lib/mongoid/cursor.rb, line 60
def initialize(klass, collection, cursor)
  @klass, @collection, @cursor = klass, collection, cursor
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.