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
- 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
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.
-
#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.
-
#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.
140 141 142 |
# File 'lib/mongo/operation/specifiable.rb', line 140 def spec @spec end |
Instance Method Details
#==(other) ⇒ true, false Also known as: eql?
Check equality of two specifiable operations.
152 153 154 155 |
# File 'lib/mongo/operation/specifiable.rb', line 152 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.
350 351 352 |
# File 'lib/mongo/operation/specifiable.rb', line 350 def bypass_document_validation spec[BYPASS_DOC_VALIDATION] end |
#coll_name ⇒ String
The name of the collection to which the operation should be sent.
226 227 228 |
# File 'lib/mongo/operation/specifiable.rb', line 226 def coll_name spec[COLL_NAME] end |
#cursor_count ⇒ Integer
Get the cursor count from the spec.
166 167 168 |
# File 'lib/mongo/operation/specifiable.rb', line 166 def cursor_count spec[CURSOR_COUNT] end |
#cursor_id ⇒ Integer
The id of the cursor created on the server.
238 239 240 |
# File 'lib/mongo/operation/specifiable.rb', line 238 def cursor_id spec[CURSOR_ID] end |
#cursor_ids ⇒ Array<Integer>
The ids of the cursors to kill from the spec.
250 251 252 |
# File 'lib/mongo/operation/specifiable.rb', line 250 def cursor_ids spec[CURSOR_IDS] end |
#db_name ⇒ String
The name of the database to which the operation should be sent.
178 179 180 |
# File 'lib/mongo/operation/specifiable.rb', line 178 def db_name spec[DB_NAME] end |
#delete ⇒ Hash
Get the delete document from the specification.
202 203 204 |
# File 'lib/mongo/operation/specifiable.rb', line 202 def delete spec[DELETE] end |
#deletes ⇒ Array<BSON::Document>
Get the deletes from the specification.
190 191 192 |
# File 'lib/mongo/operation/specifiable.rb', line 190 def deletes spec[DELETES] end |
#documents ⇒ Array<BSON::Document>
The documents to in the specification.
214 215 216 |
# File 'lib/mongo/operation/specifiable.rb', line 214 def documents spec[DOCUMENTS] end |
#index ⇒ Hash
Get the index from the specification.
262 263 264 |
# File 'lib/mongo/operation/specifiable.rb', line 262 def index spec[INDEX] end |
#index_name ⇒ String
Get the index name from the spec.
274 275 276 |
# File 'lib/mongo/operation/specifiable.rb', line 274 def index_name spec[INDEX_NAME] end |
#indexes ⇒ Hash
Get the indexes from the specification.
286 287 288 |
# File 'lib/mongo/operation/specifiable.rb', line 286 def indexes spec[INDEXES] end |
#initialize(spec) ⇒ Object
Create the new specifiable operation.
301 302 303 |
# File 'lib/mongo/operation/specifiable.rb', line 301 def initialize(spec) @spec = spec end |
#namespace ⇒ String
The namespace, consisting of the db name and collection name.
468 469 470 |
# File 'lib/mongo/operation/specifiable.rb', line 468 def namespace "#{db_name}.#{coll_name}" end |
#operation_id ⇒ Integer
Get the operation id for the operation. Used for linking operations in monitoring.
314 315 316 |
# File 'lib/mongo/operation/specifiable.rb', line 314 def operation_id spec[OPERATION_ID] end |
#options ⇒ Hash
Get the options for the operation.
326 327 328 |
# File 'lib/mongo/operation/specifiable.rb', line 326 def spec[OPTIONS] || {} end |
#ordered? ⇒ true, false
Whether the operation is ordered.
456 457 458 |
# File 'lib/mongo/operation/specifiable.rb', line 456 def ordered? !!(@spec.fetch(:ordered, true)) end |
#read ⇒ Mongo::ServerSelector
The read preference for this operation.
444 445 446 |
# File 'lib/mongo/operation/specifiable.rb', line 444 def read @spec[READ] || ServerSelector.get end |
#read_concern ⇒ Hash
Get the read concern from the spec.
338 339 340 |
# File 'lib/mongo/operation/specifiable.rb', line 338 def read_concern spec[READ_CONCERN] end |
#selector ⇒ Hash
The selector for from the specification.
362 363 364 |
# File 'lib/mongo/operation/specifiable.rb', line 362 def selector spec[SELECTOR] end |
#to_return ⇒ Integer
The number of documents to request from the server.
374 375 376 |
# File 'lib/mongo/operation/specifiable.rb', line 374 def to_return spec[TO_RETURN] end |
#update ⇒ Hash
The update document from the spec.
396 397 398 |
# File 'lib/mongo/operation/specifiable.rb', line 396 def update spec[UPDATE] end |
#updates ⇒ Array<BSON::Document>
The update documents from the spec.
385 386 387 |
# File 'lib/mongo/operation/specifiable.rb', line 385 def updates spec[UPDATES] end |
#user ⇒ Auth::User
The user for user related operations.
408 409 410 |
# File 'lib/mongo/operation/specifiable.rb', line 408 def user spec[USER] end |
#user_name ⇒ String
The user name from the specification.
420 421 422 |
# File 'lib/mongo/operation/specifiable.rb', line 420 def user_name spec[USER_NAME] end |
#write_concern ⇒ Mongo::WriteConcern
The write concern to use for this operation.
432 433 434 |
# File 'lib/mongo/operation/specifiable.rb', line 432 def write_concern @spec[WRITE_CONCERN] end |