class Mongo::Cursor::Builder::KillCursorsCommand

Generates a specification for a kill cursors command.

@since 2.2.0

Attributes

cursor[R]

@return [ Cursor ] cursor The cursor.

Public Class Methods

new(cursor) click to toggle source

Create the new builder.

@example Create the builder.

KillCursorsCommand.new(cursor)

@param [ Cursor ] cursor The cursor.

@since 2.2.0

# File lib/mongo/cursor/builder/kill_cursors_command.rb, line 38
def initialize(cursor)
  @cursor = cursor
end

Private Class Methods

get_cursors_list(spec) click to toggle source

Get the list of cursor ids from a spec generated by this Builder.

@example Get the list of cursor ids.

KillCursorsCommand.cursors(spec)

@return [ Hash ] The specification.

@since 2.3.0

# File lib/mongo/cursor/builder/kill_cursors_command.rb, line 83
def get_cursors_list(spec)
  spec[:selector][:cursors]
end
update_cursors(spec, ids) click to toggle source

Update a specification's list of cursor ids.

@example Update a specification's list of cursor ids.

KillCursorsCommand.update_cursors(spec, ids)

@return [ Hash ] The specification. @return [ Array ] The ids to update with.

@since 2.3.0

# File lib/mongo/cursor/builder/kill_cursors_command.rb, line 71
def update_cursors(spec, ids)
  spec[:selector].merge!(cursors: spec[:selector][:cursors] & ids)
end

Public Instance Methods

specification() click to toggle source

Get the specification.

@example Get the specification.

kill_cursors_command.specification

@return [ Hash ] The spec.

@since 2.2.0

# File lib/mongo/cursor/builder/kill_cursors_command.rb, line 50
def specification
  { selector: kill_cursors_command, db_name: database.name }
end

Private Instance Methods

kill_cursors_command() click to toggle source
# File lib/mongo/cursor/builder/kill_cursors_command.rb, line 56
def kill_cursors_command
  { :killCursors => collection_name, :cursors => [ cursor.id ] }
end