Class: Mongo::Protocol::Delete::Upconverter

Inherits:
Object
  • Object
show all
Defined in:
build/ruby-driver-v2.18/lib/mongo/protocol/delete.rb

Overview

Converts legacy delete messages to the appropriare OP_COMMAND style message.

Since:

  • 2.1.0

Constant Summary collapse

DELETE =

The delete command constant.

Since:

  • 2.2.0

'delete'.freeze
DELETES =

The deletes command constant.

Since:

  • 2.2.0

'deletes'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, filter, options) ⇒ Upconverter

Instantiate the upconverter.

Examples:

Instantiate the upconverter.

Upconverter.new('users', { name: 'test' })

Parameters:

  • collection (String)

    The name of the collection.

  • filter (BSON::Document, Hash)

    The filter or command.

Since:

  • 2.1.0



136
137
138
139
140
# File 'build/ruby-driver-v2.18/lib/mongo/protocol/delete.rb', line 136

def initialize(collection, filter, options)
  @collection = collection
  @filter = filter
  @options = options
end

Instance Attribute Details

#collectionString (readonly)

Returns collection The name of the collection.

Returns:

  • (String)

    collection The name of the collection.

Since:

  • 2.1.0



119
120
121
# File 'build/ruby-driver-v2.18/lib/mongo/protocol/delete.rb', line 119

def collection
  @collection
end

#filterBSON::Document, Hash (readonly)

Returns filter The query filter or command.

Returns:

  • (BSON::Document, Hash)

    filter The query filter or command.

Since:

  • 2.1.0



122
123
124
# File 'build/ruby-driver-v2.18/lib/mongo/protocol/delete.rb', line 122

def filter
  @filter
end

#optionsHash (readonly)

Returns options The options.

Returns:

  • (Hash)

    options The options.

Since:

  • 2.1.0



125
126
127
# File 'build/ruby-driver-v2.18/lib/mongo/protocol/delete.rb', line 125

def options
  @options
end

Instance Method Details

#commandBSON::Document

Get the upconverted command.

Examples:

Get the command.

upconverter.command

Returns:

  • (BSON::Document)

    The upconverted command.

Since:

  • 2.1.0



150
151
152
153
154
155
156
# File 'build/ruby-driver-v2.18/lib/mongo/protocol/delete.rb', line 150

def command
  document = BSON::Document.new
  document.store(DELETE, collection)
  document.store(DELETES, [ BSON::Document.new(Message::Q => filter, Message::LIMIT => limit) ])
  document.store(Message::ORDERED, true)
  document
end