lib/mongo/operation/shared/specifiable.rb in mongo-2.12.4 vs lib/mongo/operation/shared/specifiable.rb in mongo-2.13.0.beta1
- old
+ new
@@ -1,6 +1,6 @@
-# Copyright (C) 2014-2019 MongoDB, Inc.
+# Copyright (C) 2014-2020 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@@ -323,19 +323,19 @@
# @since 2.1.0
def operation_id
spec[OPERATION_ID]
end
- # Get the options for the operation.
+ # Get the options for executing the operation on a particular connection.
#
- # @example Get the options.
- # specifiable.options
+ # @param [ Server::Connection ] connection The connection that the
+ # operation will be executed on.
#
# @return [ Hash ] The options.
#
# @since 2.0.0
- def options(server = nil)
+ def options(connection)
spec[OPTIONS] || {}
end
# Get the read concern document from the spec.
#
@@ -385,19 +385,20 @@
# @since 2.4.0
def collation
send(self.class::IDENTIFIER).first[COLLATION]
end
- # The selector for from the specification.
+ # The selector from the specification for execution on a particular
+ # connection.
#
- # @example Get a selector specification.
- # specifiable.selector.
+ # @param [ Server::Connection ] connection The connection that the
+ # operation will be executed on.
#
# @return [ Hash ] The selector spec.
#
# @since 2.0.0
- def selector(server = nil)
+ def selector(connection)
spec[SELECTOR]
end
# The number of documents to request from the server.
#
@@ -476,11 +477,13 @@
#
# @return [ Mongo::ServerSelector ] The read preference.
#
# @since 2.0.0
def read
- @read ||= ServerSelector.get(spec[READ]) if spec[READ]
+ @read ||= begin
+ ServerSelector.get(spec[READ]) if spec[READ]
+ end
end
# Whether the operation is ordered.
#
# @example Get the ordered value, true is the default.
@@ -527,31 +530,40 @@
# @since 2.5.0
def txn_num
@spec[:txn_num]
end
+ # For createIndexes operations, the number of votes that a primary must
+ # wait for before commiting an index. Potential values are:
+ # - an integer from 0 to the number of members of the replica set
+ # - "majority" indicating that a majority of data bearing nodes must vote
+ # - "votingMembers" which means that all voting data bearing nodes must vote
+ #
+ # @return [ nil | Integer | String ] The commitQuorum value of the operation.
+ def commit_quorum
+ @spec[:commit_quorum]
+ end
+
# The command.
#
- # @example Get the command.
- # specifiable.command
- #
# @return [ Hash ] The command.
#
# @since 2.5.2
- def command(server = nil)
- selector(server)
+ def command(connection)
+ selector(connection)
end
# The array filters.
#
- # @example Get the array filters.
- # specifiable.array_filters
+ # @param [ Server::Connection ] connection The connection that the
+ # operation will be executed on.
#
- # @return [ Hash ] The array filters.
+ # @return [ Hash | nil ] The array filters.
#
# @since 2.5.2
- def array_filters
- selector[Operation::ARRAY_FILTERS] if selector
+ def array_filters(connection)
+ sel = selector(connection)
+ sel[Operation::ARRAY_FILTERS] if sel
end
# Does the operation have an acknowledged write concern.
#
# @example Determine whether the operation has an acknowledged write.