Class Moped::Cursor
In: lib/moped/cursor.rb
Parent: Object

Contains logic for cursor behaviour.

@api private

Methods

each   get_more   kill   limited?   load_docs   more?   new   request_limit  

Included Modules

Readable Enumerable Retryable

Attributes

get_more_op  [R]  @attribute [r] get_more_op The get more message. @attribute [r] kill_cursor_op The kill cursor message. @attribute [r] query_op The query message. @attribute [r] session The session.
kill_cursor_op  [R]  @attribute [r] get_more_op The get more message. @attribute [r] kill_cursor_op The kill cursor message. @attribute [r] query_op The query message. @attribute [r] session The session.
query_op  [R]  @attribute [r] get_more_op The get more message. @attribute [r] kill_cursor_op The kill cursor message. @attribute [r] query_op The query message. @attribute [r] session The session.
session  [R]  @attribute [r] get_more_op The get more message. @attribute [r] kill_cursor_op The kill cursor message. @attribute [r] query_op The query message. @attribute [r] session The session.

Public Class methods

Initialize the new cursor.

@example Create the new cursor.

  Cursor.new(session, message)

@param [ Session ] session The session. @param [ Message ] query_operation The query message.

@since 1.0.0

Public Instance methods

Iterate over the results of the query.

@example Iterate over the results.

  cursor.each do |doc|
    #...
  end

@return [ Enumerator ] The cursor enum.

@since 1.0.0

Get more documents from the database for the cursor. Executes a get more command.

@example Get more docs.

  cursor.get_more

@return [ Array<Hash> ] The next batch of documents.

@since 1.0.0

Kill the cursor.

@example Kill the cursor.

  cursor.kill

@return [ Object ] The result of the kill cursors command.

@since 1.0.0

Does the cursor have a limit provided in the query?

@example Is the cursor limited?

  cursor.limited?

@return [ true, false ] If a limit has been provided over zero.

@since 1.0.0

Load the documents from the database.

@example Load the documents.

  cursor.load_docs

@return [ Array<Hash> ] The documents.

@since 1.0.0

Are there more documents to be returned from the database?

@example Are there more documents?

  cursor.more?

@return [ true, false ] If there are more documents to load.

@since 1.0.0

Determine the request limit for the query

@example What is the cursor request_limit

  cursor.request_limit

@return [ Integer ]

@since 1.0.0

[Validate]