Class: Mongo::Cursor::Builder::OpKillCursors

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

Overview

Encapsulates behaviour around generating an OP_KILL_CURSORS specification.

Since:

  • 2.2.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cursor) ⇒ OpKillCursors

Create the new builder.

Examples:

Create the builder.

OpKillCursors.new(cursor)

Parameters:

  • cursor (Cursor)

    The cursor.

Since:

  • 2.2.0



38
39
40
# File 'lib/mongo/cursor/builder/op_kill_cursors.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/op_kill_cursors.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.

OpKillCursors.cursors(spec)

Returns:

  • (Hash)

    The specification.

Since:

  • 2.3.0



77
78
79
# File 'lib/mongo/cursor/builder/op_kill_cursors.rb', line 77

def get_cursors_list(spec)
  spec[:cursor_ids]
end

.update_cursors(spec, ids) ⇒ Hash, Array

Update a specification's list of cursor ids.

Examples:

Update a specification's list of cursor ids.

OpKillCursors.update_cursors(spec, ids)

Returns:

  • (Hash)

    The specification.

  • (Array)

    The ids to update with.

Since:

  • 2.3.0



65
66
67
# File 'lib/mongo/cursor/builder/op_kill_cursors.rb', line 65

def update_cursors(spec, ids)
  spec.merge!(cursor_ids: spec[:cursor_ids] & ids)
end

Instance Method Details

#specificationHash

Get the specification.

Examples:

Get the specification.

op_kill_cursors.specification

Returns:

  • (Hash)

    The specification.

Since:

  • 2.2.0



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

def specification
  { :coll_name => collection_name, :db_name => database.name, :cursor_ids => [ cursor.id ] }
end