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

Inherits:
Object
  • Object
show all
Defined in:
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



130
131
132
133
134
# File 'lib/mongo/protocol/delete.rb', line 130

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



113
114
115
# File 'lib/mongo/protocol/delete.rb', line 113

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



116
117
118
# File 'lib/mongo/protocol/delete.rb', line 116

def filter
  @filter
end

#optionsHash (readonly)

Returns options The options.

Returns:

  • (Hash)

    options The options.

Since:

  • 2.1.0



119
120
121
# File 'lib/mongo/protocol/delete.rb', line 119

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



144
145
146
147
148
149
150
# File 'lib/mongo/protocol/delete.rb', line 144

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