class Mongo::Cursor::Builder::GetMoreCommand

Generates a specification for a get more command.

@since 2.2.0

Attributes

cursor[R]

@return [ Cursor ] cursor The cursor.

Public Class Methods

new(cursor, session = nil) click to toggle source

Create the new builder.

@example Create the builder.

GetMoreCommand.new(cursor)

@param [ Cursor ] cursor The cursor. @param [ Session ] session The session.

@since 2.2.0

# File lib/mongo/cursor/builder/get_more_command.rb, line 40
def initialize(cursor, session = nil)
  @cursor = cursor
  @session = session
end

Public Instance Methods

specification() click to toggle source

Get the specification.

@example Get the specification.

get_more_command.specification

@return [ Hash ] The spec.

@since 2.2.0

# File lib/mongo/cursor/builder/get_more_command.rb, line 53
def specification
  { selector: get_more_command, db_name: database.name, session: @session }
end

Private Instance Methods

get_more_command() click to toggle source
# File lib/mongo/cursor/builder/get_more_command.rb, line 59
def get_more_command
  command = {
    :getMore => BSON::Int64.new(cursor.id),
    :collection => collection_name,
  }
  command[:batchSize] = batch_size.abs if batch_size && batch_size != 0
  # If the max_await_time_ms option is set, then we set maxTimeMS on
  # the get more command.
  if view.respond_to?(:max_await_time_ms)
    if view.max_await_time_ms && view.options[:await_data]
      command[:maxTimeMS] = view.max_await_time_ms
    end
  end
  command
end