Class: Mongo::Cursor::Builder::KillCursorsCommand

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/mongo/cursor/builder/kill_cursors_command.rb

Overview

Generates a specification for a kill cursors command.

Since:

  • 2.2.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cursor) ⇒ KillCursorsCommand

Create the new builder.

Examples:

Create the builder.

KillCursorsCommand.new(cursor)

Parameters:

  • cursor (Cursor)

    The cursor.

Since:

  • 2.2.0



38
39
40
# File 'lib/mongo/cursor/builder/kill_cursors_command.rb', line 38

def initialize(cursor)
  @cursor = cursor
end

Instance Attribute Details

#cursorCursor (readonly)

Returns cursor The cursor.

Returns:

  • (Cursor)

    cursor The cursor.

Since:

  • 2.2.0



26
27
28
# File 'lib/mongo/cursor/builder/kill_cursors_command.rb', line 26

def cursor
  @cursor
end

Class Method Details

.get_cursors_list(spec) ⇒ Hash

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

Examples:

Get the list of cursor ids.

KillCursorsCommand.cursors(spec)

Returns:

  • (Hash)

    The specification.

Since:

  • 2.3.0



83
84
85
# File 'lib/mongo/cursor/builder/kill_cursors_command.rb', line 83

def get_cursors_list(spec)
  spec[:selector][:cursors]
end

.update_cursors(spec, ids) ⇒ Hash, Array

Update a specification's list of cursor ids.

Examples:

Update a specification's list of cursor ids.

KillCursorsCommand.update_cursors(spec, ids)

Returns:

  • (Hash)

    The specification.

  • (Array)

    The ids to update with.

Since:

  • 2.3.0



71
72
73
# 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

Instance Method Details

#specificationHash

Get the specification.

Examples:

Get the specification.

kill_cursors_command.specification

Returns:

  • (Hash)

    The spec.

Since:

  • 2.2.0



50
51
52
# File 'lib/mongo/cursor/builder/kill_cursors_command.rb', line 50

def specification
  { selector: kill_cursors_command, db_name: database.name }
end