Module: Mongo::Operation::Specifiable Private

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

This module contains common functionality for convenience methods getting various values from the spec.

Since:

  • 2.0.0

Constant Summary collapse

DB_NAME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for database name.

Since:

  • 2.0.0

:db_name.freeze
DELETES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for deletes.

Since:

  • 2.0.0

:deletes.freeze
DELETE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for delete.

Since:

  • 2.0.0

:delete.freeze
DOCUMENTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for documents.

Since:

  • 2.0.0

:documents.freeze
COLL_NAME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for collection name.

Since:

  • 2.0.0

:coll_name.freeze
CURSOR_COUNT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for cursor count.

Since:

  • 2.0.0

:cursor_count.freeze
CURSOR_ID =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for cursor id.

Since:

  • 2.0.0

:cursor_id.freeze
INDEX =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for an index.

Since:

  • 2.0.0

:index.freeze
INDEXES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for multiple indexes.

Since:

  • 2.0.0

:indexes.freeze
INDEX_NAME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for index names.

Since:

  • 2.0.0

:index_name.freeze
OPERATION_ID =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The operation id constant.

Since:

  • 2.1.0

:operation_id.freeze
OPTIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for options.

Since:

  • 2.0.0

:options.freeze
READ_CONCERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The read concern option.

Since:

  • 2.2.0

:read_concern.freeze
MAX_TIME_MS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The max time ms option.

Since:

  • 2.2.5

:max_time_ms.freeze
SELECTOR =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for a selector.

Since:

  • 2.0.0

:selector.freeze
TO_RETURN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for number to return.

Since:

  • 2.0.0

:to_return.freeze
UPDATES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for updates.

Since:

  • 2.0.0

:updates.freeze
UPDATE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field for update.

Since:

  • 2.0.0

:update.freeze
USER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field name for a user.

Since:

  • 2.0.0

:user.freeze
USER_NAME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field name for user name.

Since:

  • 2.0.0

:user_name.freeze
WRITE_CONCERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field name for a write concern.

Since:

  • 2.0.0

:write_concern.freeze
READ =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The field name for the read preference.

Since:

  • 2.0.0

:read.freeze
BYPASS_DOC_VALIDATION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Whether to bypass document level validation.

Since:

  • 2.2.0

:bypass_document_validation.freeze
COLLATION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

A collation to apply to the operation.

Since:

  • 2.4.0

:collation.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#specHash (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns spec The specification for the operation.

Returns:

  • (Hash)

    spec The specification for the operation.

Since:

  • 2.0.0



149
150
151
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 149

def spec
  @spec
end

Instance Method Details

#==(other) ⇒ true, false Also known as: eql?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check equality of two specifiable operations.

Examples:

Are the operations equal?

operation == other

Parameters:

  • other (Object)

    The other operation.

Returns:

  • (true, false)

    Whether the objects are equal.

Since:

  • 2.0.0



161
162
163
164
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 161

def ==(other)
  return false unless other.is_a?(Specifiable)
  spec == other.spec
end

#acknowledged_write?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Does the operation have an acknowledged write concern.

Examples:

Determine whether the operation has an acknowledged write.

specifiable.array_filters

Returns:

  • (Boolean)

    Whether or not the operation has an acknowledged write concern.

Since:

  • 2.5.2



552
553
554
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 552

def acknowledged_write?
  write_concern.nil? || write_concern.acknowledged?
end

#apply_collation(selector, connection, collation) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



556
557
558
559
560
561
562
563
564
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 556

def apply_collation(selector, connection, collation)
  if collation
    unless connection.features.collation_enabled?
      raise Error::UnsupportedCollation
    end
    selector = selector.merge(collation: collation)
  end
  selector
end

#array_filters(connection) ⇒ Hash | nil

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The array filters.

Parameters:

  • connection (Server::Connection)

    The connection that the operation will be executed on.

Returns:

  • (Hash | nil)

    The array filters.

Since:

  • 2.5.2



539
540
541
542
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 539

def array_filters(connection)
  sel = selector(connection)
  sel[Operation::ARRAY_FILTERS] if sel
end

#bypass_document_validationtrue, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Whether or not to bypass document level validation.

Examples:

Get the bypass_document_validation option.

specifiable.bypass_documentation_validation.

Returns:

  • (true, false)

    Whether to bypass document level validation.

Since:

  • 2.2.0



361
362
363
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 361

def bypass_document_validation
  spec[BYPASS_DOC_VALIDATION]
end

#coll_nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The name of the collection to which the operation should be sent.

Examples:

Get the collection name.

specifiable.coll_name

Returns:

  • (String)

    Collection name.

Since:

  • 2.0.0



235
236
237
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 235

def coll_name
  spec.fetch(COLL_NAME)
end

#collationHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The collation to apply to the operation.

Examples:

Get the collation option.

specifiable.collation.

Returns:

  • (Hash)

    The collation document.

Since:

  • 2.4.0



373
374
375
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 373

def collation
  send(self.class::IDENTIFIER).first[COLLATION]
end

#command(connection) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The command.

Returns:

  • (Hash)

    The command.

Since:

  • 2.5.2



527
528
529
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 527

def command(connection)
  selector(connection)
end

#cursor_countInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the cursor count from the spec.

Examples:

Get the cursor count.

specifiable.cursor_count

Returns:

  • (Integer)

    The cursor count.

Since:

  • 2.0.0



175
176
177
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 175

def cursor_count
  spec[CURSOR_COUNT]
end

#cursor_idInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The id of the cursor created on the server.

Examples:

Get the cursor id.

specifiable.cursor_id

Returns:

  • (Integer)

    The cursor id.

Since:

  • 2.0.0



247
248
249
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 247

def cursor_id
  spec[CURSOR_ID]
end

#db_nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The name of the database to which the operation should be sent.

Examples:

Get the database name.

specifiable.db_name

Returns:

  • (String)

    Database name.

Since:

  • 2.0.0



187
188
189
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 187

def db_name
  spec[DB_NAME]
end

#deleteHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the delete document from the specification.

Examples:

Get the delete document.

specifiable.delete

Returns:

  • (Hash)

    The delete document.

Since:

  • 2.0.0



211
212
213
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 211

def delete
  spec[DELETE]
end

#deletesArray<BSON::Document>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the deletes from the specification.

Examples:

Get the deletes.

specifiable.deletes

Returns:

  • (Array<BSON::Document>)

    The deletes.

Since:

  • 2.0.0



199
200
201
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 199

def deletes
  spec[DELETES]
end

#documentsArray<BSON::Document>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The documents to in the specification.

Examples:

Get the documents.

specifiable.documents

Returns:

  • (Array<BSON::Document>)

    The documents.

Since:

  • 2.0.0



223
224
225
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 223

def documents
  spec[DOCUMENTS]
end

#indexHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the index from the specification.

Examples:

Get the index specification.

specifiable.index

Returns:

  • (Hash)

    The index specification.

Since:

  • 2.0.0



259
260
261
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 259

def index
  spec[INDEX]
end

#index_nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the index name from the spec.

Examples:

Get the index name.

specifiable.index_name

Returns:

  • (String)

    The index name.

Since:

  • 2.0.0



271
272
273
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 271

def index_name
  spec[INDEX_NAME]
end

#indexesHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the indexes from the specification.

Examples:

Get the index specifications.

specifiable.indexes

Returns:

  • (Hash)

    The index specifications.

Since:

  • 2.0.0



283
284
285
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 283

def indexes
  spec[INDEXES]
end

#initialize(spec) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create the new specifiable operation.

Examples:

Create the new specifiable operation.

Specifiable.new(spec)

Parameters:

  • spec (Hash)

    The operation specification.

See Also:

  • individual operations for the values they require in their specs.

Since:

  • 2.0.0



298
299
300
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 298

def initialize(spec)
  @spec = spec
end

#max_time_msHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the max time ms value from the spec.

Examples:

Get the max time ms.

specifiable.max_time_ms

Returns:

  • (Hash)

    The max time ms value.

Since:

  • 2.2.5



349
350
351
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 349

def max_time_ms
  spec[MAX_TIME_MS]
end

#namespaceString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The namespace, consisting of the db name and collection name.

Examples:

Get the namespace.

specifiable.namespace

Returns:

  • (String)

    The namespace.

Since:

  • 2.1.0



494
495
496
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 494

def namespace
  "#{db_name}.#{coll_name}"
end

#operation_idInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the operation id for the operation. Used for linking operations in monitoring.

Examples:

Get the operation id.

specifiable.operation_id

Returns:

  • (Integer)

    The operation id.

Since:

  • 2.1.0



311
312
313
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 311

def operation_id
  spec[OPERATION_ID]
end

#options(connection) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the options for executing the operation on a particular connection.

Parameters:

  • connection (Server::Connection)

    The connection that the operation will be executed on.

Returns:

  • (Hash)

    The options.

Since:

  • 2.0.0



323
324
325
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 323

def options(connection)
  spec[OPTIONS] || {}
end

#ordered?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Whether the operation is ordered.

Examples:

Get the ordered value, true is the default.

specifiable.ordered?

Returns:

  • (true, false)

    Whether the operation is ordered.

Since:

  • 2.1.0



482
483
484
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 482

def ordered?
  !!(@spec.fetch(:ordered, true))
end

#readMongo::ServerSelector

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The read preference for this operation.

Examples:

Get the read preference.

specifiable.read

Returns:

Since:

  • 2.0.0



468
469
470
471
472
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 468

def read
  @read ||= begin
    ServerSelector.get(spec[READ]) if spec[READ]
  end
end

#read_concernHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

The document may include afterClusterTime.

Get the read concern document from the spec.

Examples:

Get the read concern.

specifiable.read_concern

Returns:

  • (Hash)

    The read concern document.

Since:

  • 2.2.0



337
338
339
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 337

def read_concern
  spec[READ_CONCERN]
end

#selector(connection) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The selector from the specification for execution on a particular connection.

Parameters:

  • connection (Server::Connection)

    The connection that the operation will be executed on.

Returns:

  • (Hash)

    The selector spec.

Since:

  • 2.0.0



386
387
388
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 386

def selector(connection)
  spec[SELECTOR]
end

#sessionSession

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The session to use for the operation.

Examples:

Get the session.

specifiable.session

Returns:

Since:

  • 2.5.0



506
507
508
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 506

def session
  @spec[:session]
end

#to_returnInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The number of documents to request from the server.

Examples:

Get the to return value from the spec.

specifiable.to_return

Returns:

  • (Integer)

    The number of documents to return.

Since:

  • 2.0.0



398
399
400
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 398

def to_return
  spec[TO_RETURN]
end

#txn_numInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The transaction number for the operation.

Examples:

Get the transaction number.

specifiable.txn_num

Returns:

  • (Integer)

    The transaction number.

Since:

  • 2.5.0



518
519
520
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 518

def txn_num
  @spec[:txn_num]
end

#updateHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The update document from the spec.

Examples:

Get the update document.

Returns:

  • (Hash)

    The update document.

Since:

  • 2.0.0



420
421
422
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 420

def update
  spec[UPDATE]
end

#updatesArray<BSON::Document>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The update documents from the spec.

Examples:

Get the update documents.

Returns:

  • (Array<BSON::Document>)

    The update documents.

Since:

  • 2.0.0



409
410
411
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 409

def updates
  spec[UPDATES]
end

#userAuth::User

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The user for user related operations.

Examples:

Get the user.

specifiable.user

Returns:

Since:

  • 2.0.0



432
433
434
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 432

def user
  spec[USER]
end

#user_nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The user name from the specification.

Examples:

Get the user name.

specifiable.user_name

Returns:

  • (String)

    The user name.

Since:

  • 2.0.



444
445
446
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 444

def user_name
  spec[USER_NAME]
end

#write_concernMongo::WriteConcern

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The write concern to use for this operation.

Examples:

Get the write concern.

specifiable.write_concern

Returns:

Since:

  • 2.0.0



456
457
458
# File 'build/ruby-driver-v2.19/lib/mongo/operation/shared/specifiable.rb', line 456

def write_concern
  @spec[WRITE_CONCERN]
end