module Mongo::Operation::CollectionsInfoOrListCollections

@api private

Public Instance Methods

execute(server, client:) click to toggle source

Execute the operation.

@example

operation.execute(server, client: nil)

@param [ Mongo::Server ] server The server to send the operation to. @param [ Mongo::Client ] client The client that will be used to

perform auto-encryption if it is necessary to encrypt the command
being executed (optional).

@return [ Mongo::Operation::CollectionsInfo::Result,

Mongo::Operation::ListCollections::Result ] The operation result.
# File lib/mongo/operation/shared/collections_info_or_list_collections.rb, line 34
def execute(server, client:)
  server.with_connection do |connection|
    operation = final_operation(connection)
    operation.execute(connection, client: client)
  end
end

Private Instance Methods

final_operation(connection) click to toggle source
# File lib/mongo/operation/shared/collections_info_or_list_collections.rb, line 43
def final_operation(connection)
   op_class = if connection.features.list_collections_enabled?
    if connection.features.op_msg_enabled?
      ListCollections::OpMsg
    else
      ListCollections::Command
    end
  else
    CollectionsInfo::Command
  end

  op_class.new(spec)
end