Module: Mongo::Operation::Specifiable
- Included in:
- Commands::CollectionsInfo, Commands::Command, Commands::Indexes, Commands::UserQuery, KillCursors, Read::GetMore, Read::Query, Write::Bulk::Delete, Write::Bulk::Insert, Write::Bulk::Update, Write::Command::CreateIndex, Write::Command::CreateUser, Write::Command::Delete, Write::Command::DropIndex, Write::Command::Insert, Write::Command::RemoveUser, Write::Command::Update, Write::Command::UpdateUser, Write::CreateIndex, Write::CreateUser, Write::Delete, Write::DropIndex, Write::Insert, Write::RemoveUser, Write::Update, Write::UpdateUser
- Defined in:
- lib/mongo/operation/specifiable.rb
Overview
This module contains common functionality for convenience methods getting various values from the spec.
Constant Summary collapse
- DB_NAME =
The field for database name.
:db_name.freeze
- DELETES =
The field for deletes.
:deletes.freeze
- DELETE =
The field for delete.
:delete.freeze
- DOCUMENTS =
The field for documents.
:documents.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
- CURSOR_IDS =
The field for cursor ids.
:cursor_ids.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
- OPERATION_ID =
The operation id constant.
:operation_id.freeze
- OPTIONS =
The field for options.
:options.freeze
- READ_CONCERN =
The read concern option.
:read_concern.freeze
- MAX_TIME_MS =
The max time ms option.
:max_time_ms.freeze
- SELECTOR =
The field for a selector.
:selector.freeze
- TO_RETURN =
The field for number to return.
:to_return.freeze
- UPDATES =
The field for updates.
:updates.freeze
- UPDATE =
The field for update.
:update.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
- READ =
The field name for the read preference.
:read.freeze
- BYPASS_DOC_VALIDATION =
Whether to bypass document level validation.
:bypass_document_validation.freeze
- COLLATION =
A collation to apply to the operation.
:collation.freeze
Instance Attribute Summary collapse
-
#spec ⇒ Hash
readonly
Spec The specification for the operation.
Instance Method Summary collapse
-
#==(other) ⇒ true, false
(also: #eql?)
Check equality of two specifiable operations.
-
#bypass_document_validation ⇒ true, false
Whether or not to bypass document level validation.
-
#coll_name ⇒ String
The name of the collection to which the operation should be sent.
-
#collation ⇒ Hash
The collation to apply to the operation.
-
#cursor_count ⇒ Integer
Get the cursor count from the spec.
-
#cursor_id ⇒ Integer
The id of the cursor created on the server.
-
#cursor_ids ⇒ Array<Integer>
The ids of the cursors to kill from the spec.
-
#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.
-
#index ⇒ Hash
Get the index from the specification.
-
#index_name ⇒ String
Get the index name from the spec.
-
#indexes ⇒ Hash
Get the indexes from the specification.
-
#initialize(spec) ⇒ Object
Create the new specifiable operation.
-
#max_time_ms ⇒ Hash
Get the max time ms value from the spec.
-
#namespace ⇒ String
The namespace, consisting of the db name and collection name.
-
#operation_id ⇒ Integer
Get the operation id for the operation.
-
#options ⇒ Hash
Get the options for the operation.
-
#ordered? ⇒ true, false
Whether the operation is ordered.
-
#read ⇒ Mongo::ServerSelector
The read preference for this operation.
-
#read_concern ⇒ Hash
Get the read concern from the spec.
-
#selector ⇒ Hash
The selector for from the specification.
-
#to_return ⇒ Integer
The number of documents to request from the server.
-
#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.
Instance Attribute Details
#spec ⇒ Hash (readonly)
Returns spec The specification for the operation.
150 151 152 |
# File 'lib/mongo/operation/specifiable.rb', line 150 def spec @spec end |
Instance Method Details
#==(other) ⇒ true, false Also known as: eql?
Check equality of two specifiable operations.
162 163 164 165 |
# File 'lib/mongo/operation/specifiable.rb', line 162 def ==(other) return false unless other.is_a?(Specifiable) spec == other.spec end |
#bypass_document_validation ⇒ true, false
Whether or not to bypass document level validation.
372 373 374 |
# File 'lib/mongo/operation/specifiable.rb', line 372 def bypass_document_validation spec[BYPASS_DOC_VALIDATION] end |
#coll_name ⇒ String
The name of the collection to which the operation should be sent.
236 237 238 |
# File 'lib/mongo/operation/specifiable.rb', line 236 def coll_name spec[COLL_NAME] end |
#collation ⇒ Hash
The collation to apply to the operation.
384 385 386 |
# File 'lib/mongo/operation/specifiable.rb', line 384 def collation spec[COLLATION] end |
#cursor_count ⇒ Integer
Get the cursor count from the spec.
176 177 178 |
# File 'lib/mongo/operation/specifiable.rb', line 176 def cursor_count spec[CURSOR_COUNT] end |
#cursor_id ⇒ Integer
The id of the cursor created on the server.
248 249 250 |
# File 'lib/mongo/operation/specifiable.rb', line 248 def cursor_id spec[CURSOR_ID] end |
#cursor_ids ⇒ Array<Integer>
The ids of the cursors to kill from the spec.
260 261 262 |
# File 'lib/mongo/operation/specifiable.rb', line 260 def cursor_ids spec[CURSOR_IDS] end |
#db_name ⇒ String
The name of the database to which the operation should be sent.
188 189 190 |
# File 'lib/mongo/operation/specifiable.rb', line 188 def db_name spec[DB_NAME] end |
#delete ⇒ Hash
Get the delete document from the specification.
212 213 214 |
# File 'lib/mongo/operation/specifiable.rb', line 212 def delete spec[DELETE] end |
#deletes ⇒ Array<BSON::Document>
Get the deletes from the specification.
200 201 202 |
# File 'lib/mongo/operation/specifiable.rb', line 200 def deletes spec[DELETES] end |
#documents ⇒ Array<BSON::Document>
The documents to in the specification.
224 225 226 |
# File 'lib/mongo/operation/specifiable.rb', line 224 def documents spec[DOCUMENTS] end |
#index ⇒ Hash
Get the index from the specification.
272 273 274 |
# File 'lib/mongo/operation/specifiable.rb', line 272 def index spec[INDEX] end |
#index_name ⇒ String
Get the index name from the spec.
284 285 286 |
# File 'lib/mongo/operation/specifiable.rb', line 284 def index_name spec[INDEX_NAME] end |
#indexes ⇒ Hash
Get the indexes from the specification.
296 297 298 |
# File 'lib/mongo/operation/specifiable.rb', line 296 def indexes spec[INDEXES] end |
#initialize(spec) ⇒ Object
Create the new specifiable operation.
311 312 313 |
# File 'lib/mongo/operation/specifiable.rb', line 311 def initialize(spec) @spec = spec end |
#max_time_ms ⇒ Hash
Get the max time ms value from the spec.
360 361 362 |
# File 'lib/mongo/operation/specifiable.rb', line 360 def max_time_ms spec[MAX_TIME_MS] end |
#namespace ⇒ String
The namespace, consisting of the db name and collection name.
502 503 504 |
# File 'lib/mongo/operation/specifiable.rb', line 502 def namespace "#{db_name}.#{coll_name}" end |
#operation_id ⇒ Integer
Get the operation id for the operation. Used for linking operations in monitoring.
324 325 326 |
# File 'lib/mongo/operation/specifiable.rb', line 324 def operation_id spec[OPERATION_ID] end |
#options ⇒ Hash
Get the options for the operation.
336 337 338 |
# File 'lib/mongo/operation/specifiable.rb', line 336 def spec[OPTIONS] || {} end |
#ordered? ⇒ true, false
Whether the operation is ordered.
490 491 492 |
# File 'lib/mongo/operation/specifiable.rb', line 490 def ordered? !!(@spec.fetch(:ordered, true)) end |
#read ⇒ Mongo::ServerSelector
The read preference for this operation.
478 479 480 |
# File 'lib/mongo/operation/specifiable.rb', line 478 def read @read ||= ServerSelector.get(@spec[READ] || ServerSelector::PRIMARY) end |
#read_concern ⇒ Hash
Get the read concern from the spec.
348 349 350 |
# File 'lib/mongo/operation/specifiable.rb', line 348 def read_concern spec[READ_CONCERN] end |
#selector ⇒ Hash
The selector for from the specification.
396 397 398 |
# File 'lib/mongo/operation/specifiable.rb', line 396 def selector spec[SELECTOR] end |
#to_return ⇒ Integer
The number of documents to request from the server.
408 409 410 |
# File 'lib/mongo/operation/specifiable.rb', line 408 def to_return spec[TO_RETURN] end |
#update ⇒ Hash
The update document from the spec.
430 431 432 |
# File 'lib/mongo/operation/specifiable.rb', line 430 def update spec[UPDATE] end |
#updates ⇒ Array<BSON::Document>
The update documents from the spec.
419 420 421 |
# File 'lib/mongo/operation/specifiable.rb', line 419 def updates spec[UPDATES] end |
#user ⇒ Auth::User
The user for user related operations.
442 443 444 |
# File 'lib/mongo/operation/specifiable.rb', line 442 def user spec[USER] end |
#user_name ⇒ String
The user name from the specification.
454 455 456 |
# File 'lib/mongo/operation/specifiable.rb', line 454 def user_name spec[USER_NAME] end |
#write_concern ⇒ Mongo::WriteConcern
The write concern to use for this operation.
466 467 468 |
# File 'lib/mongo/operation/specifiable.rb', line 466 def write_concern @spec[WRITE_CONCERN] end |