Module: Mongo::Operation::Specifiable Private
Overview
This module contains common functionality for convenience methods getting various values from the spec.
Constant Summary
-
BYPASS_DOC_VALIDATION =
Whether to bypass document level validation.
:bypass_document_validation.freeze
-
COLLATION =
A collation to apply to the operation.
:collation.freeze
-
COLL_NAME =
The field for collection name.
:coll_name.freeze
-
CURSOR_COUNT =
The field for cursor count.
:cursor_count.freeze
-
CURSOR_ID =
The field for cursor id.
:cursor_id.freeze
-
DB_NAME =
The field for database name.
:db_name.freeze
-
DELETE =
The field for delete.
:delete.freeze
-
DELETES =
The field for deletes.
:deletes.freeze
-
DOCUMENTS =
The field for documents.
:documents.freeze
-
INDEX =
The field for an index.
:index.freeze
-
INDEXES =
The field for multiple indexes.
:indexes.freeze
-
INDEX_NAME =
The field for index names.
:index_name.freeze
-
MAX_TIME_MS =
The max time ms option.
:max_time_ms.freeze
-
OPERATION_ID =
The operation id constant.
:operation_id.freeze
-
OPTIONS =
The field for options.
: .freeze
-
READ =
The field name for the read preference.
:read.freeze
-
READ_CONCERN =
The read concern option.
:read_concern.freeze
-
SELECTOR =
The field for a selector.
:selector.freeze
-
TO_RETURN =
The field for number to return.
:to_return.freeze
-
UPDATE =
The field for update.
:update.freeze
-
UPDATES =
The field for updates.
:updates.freeze
-
USER =
The field name for a user.
:user.freeze
-
USER_NAME =
The field name for user name.
:user_name.freeze
-
WRITE_CONCERN =
The field name for a write concern.
:write_concern.freeze
Instance Attribute Summary
-
#acknowledged_write? ⇒ Boolean
readonly
Internal use only
Does the operation have an acknowledged write concern.
-
#ordered? ⇒ true, false
readonly
Internal use only
Whether the operation is ordered.
- #spec ⇒ Hash readonly Internal use only
Instance Method Summary
-
#==(other) ⇒ true, false
(also: #eql?)
Internal use only
Check equality of two specifiable operations.
- #apply_collation(selector, connection, collation) Internal use only
-
#array_filters(connection) ⇒ Hash | nil
Internal use only
The array filters.
-
#bypass_document_validation ⇒ true, false
Internal use only
Whether or not to bypass document level validation.
-
#coll_name ⇒ String
Internal use only
The name of the collection to which the operation should be sent.
-
#collation ⇒ Hash
Internal use only
The collation to apply to the operation.
-
#command(connection) ⇒ Hash
Internal use only
The command.
-
#cursor_count ⇒ Integer
Internal use only
Get the cursor count from the spec.
-
#cursor_id ⇒ Integer
Internal use only
The id of the cursor created on the server.
-
#db_name ⇒ String
Internal use only
The name of the database to which the operation should be sent.
-
#delete ⇒ Hash
Internal use only
Get the delete document from the specification.
-
#deletes ⇒ Array<BSON::Document>
Internal use only
Get the deletes from the specification.
-
#documents ⇒ Array<BSON::Document>
Internal use only
The documents to in the specification.
-
#eql?(other)
Alias for #==.
-
#index ⇒ Hash
Internal use only
Get the index from the specification.
-
#index_id ⇒ String
Internal use only
Get the index id from the spec.
-
#index_name ⇒ String
Internal use only
Get the index name from the spec.
-
#indexes ⇒ Hash
Internal use only
Get the indexes from the specification.
-
#initialize(spec)
Internal use only
Create
the new specifiable operation. -
#max_time_ms ⇒ Hash
Internal use only
Get the max time ms value from the spec.
-
#namespace ⇒ String
Internal use only
The namespace, consisting of the db name and collection name.
-
#operation_id ⇒ Integer
Internal use only
Get the operation id for the operation.
-
#options(connection) ⇒ Hash
Internal use only
Get the options for executing the operation on a particular connection.
-
#read ⇒ Mongo::ServerSelector
Internal use only
The read preference for this operation.
-
#read_concern ⇒ Hash
Internal use only
Get the read concern document from the spec.
-
#selector(connection) ⇒ Hash
Internal use only
The selector from the specification for execution on a particular connection.
-
#session ⇒ Session
Internal use only
The session to use for the operation.
-
#to_return ⇒ Integer
Internal use only
The number of documents to request from the server.
-
#txn_num ⇒ Integer
Internal use only
The transaction number for the operation.
-
#update ⇒ Hash
Internal use only
The update document from the spec.
-
#updates ⇒ Array<BSON::Document>
Internal use only
The update documents from the spec.
-
#user ⇒ Auth::User
Internal use only
The user for user related operations.
-
#user_name ⇒ String
Internal use only
The user name from the specification.
-
#write_concern ⇒ Mongo::WriteConcern
Internal use only
The write concern to use for this operation.
Instance Attribute Details
#acknowledged_write? ⇒ Boolean
(readonly)
Does the operation have an acknowledged write concern.
# File 'lib/mongo/operation/shared/specifiable.rb', line 559
def acknowledged_write? write_concern.nil? || write_concern.acknowledged? end
#ordered? ⇒ true
, false
(readonly)
Whether the operation is ordered.
# File 'lib/mongo/operation/shared/specifiable.rb', line 489
def ordered? !!(@spec.fetch(:ordered, true)) end
#spec ⇒ Hash
(readonly)
# File 'lib/mongo/operation/shared/specifiable.rb', line 149
attr_reader :spec
Instance Method Details
#==(other) ⇒ true
, false
Also known as: #eql?
Check equality of two specifiable operations.
#apply_collation(selector, connection, collation)
#array_filters(connection) ⇒ Hash
| nil
The array filters.
# File 'lib/mongo/operation/shared/specifiable.rb', line 546
def array_filters(connection) sel = selector(connection) sel[Operation::ARRAY_FILTERS] if sel end
#bypass_document_validation ⇒ true
, false
Whether or not to bypass document level validation.
# File 'lib/mongo/operation/shared/specifiable.rb', line 368
def bypass_document_validation spec[BYPASS_DOC_VALIDATION] end
#coll_name ⇒ String
The name of the collection to which the operation should be sent.
#collation ⇒ Hash
The collation to apply to the operation.
# File 'lib/mongo/operation/shared/specifiable.rb', line 380
def collation send(self.class::IDENTIFIER).first[COLLATION] end
#command(connection) ⇒ Hash
The command.
# File 'lib/mongo/operation/shared/specifiable.rb', line 534
def command(connection) selector(connection) end
#cursor_count ⇒ Integer
Get the cursor count from the spec.
# File 'lib/mongo/operation/shared/specifiable.rb', line 175
def cursor_count spec[CURSOR_COUNT] end
#cursor_id ⇒ Integer
The id of the cursor created on the server.
#db_name ⇒ String
The name of the database to which the operation should be sent.
#delete ⇒ Hash
Get the delete document from the specification.
#deletes ⇒ Array
<BSON::Document
>
Get the deletes from the specification.
#documents ⇒ Array
<BSON::Document
>
The documents to in the specification.
#eql?(other)
Alias for #==.
# File 'lib/mongo/operation/shared/specifiable.rb', line 165
alias_method :eql?, :==
#index ⇒ Hash
Get the index from the specification.
#index_id ⇒ String
Get the index id from the spec.
# File 'lib/mongo/operation/shared/specifiable.rb', line 266
def index_id spec[:index_id] end
#index_name ⇒ String
Get the index name from the spec.
# File 'lib/mongo/operation/shared/specifiable.rb', line 278
def index_name spec[INDEX_NAME] end
#indexes ⇒ Hash
Get the indexes from the specification.
#initialize(spec)
Create
the new specifiable operation.
#max_time_ms ⇒ Hash
Get the max time ms value from the spec.
# File 'lib/mongo/operation/shared/specifiable.rb', line 356
def max_time_ms spec[MAX_TIME_MS] end
#namespace ⇒ String
The namespace, consisting of the db name and collection name.
#operation_id ⇒ Integer
Get the operation id for the operation. Used for linking operations in monitoring.
# File 'lib/mongo/operation/shared/specifiable.rb', line 318
def operation_id spec[OPERATION_ID] end
#options(connection) ⇒ Hash
Get the options for executing the operation on a particular connection.
#read ⇒ Mongo::ServerSelector
The read preference for this operation.
#read_concern ⇒ Hash
The document may include afterClusterTime.
Get the read concern document from the spec.
# File 'lib/mongo/operation/shared/specifiable.rb', line 344
def read_concern spec[READ_CONCERN] end
#selector(connection) ⇒ Hash
The selector from the specification for execution on a particular connection.
#session ⇒ Session
The session to use for the operation.
# File 'lib/mongo/operation/shared/specifiable.rb', line 513
def session @spec[:session] end
#to_return ⇒ Integer
The number of documents to request from the server.
#txn_num ⇒ Integer
The transaction number for the operation.
# File 'lib/mongo/operation/shared/specifiable.rb', line 525
def txn_num @spec[:txn_num] end
#update ⇒ Hash
The update document from the spec.
#updates ⇒ Array
<BSON::Document
>
The update documents from the spec.
#user ⇒ Auth::User
The user for user related operations.
#user_name ⇒ String
The user name from the specification.
#write_concern ⇒ Mongo::WriteConcern
The write concern to use for this operation.
# File 'lib/mongo/operation/shared/specifiable.rb', line 463
def write_concern @spec[WRITE_CONCERN] end