Module: Mongoid::Selectable

Extended by:
ActiveSupport::Concern
Included in:
Composable
Defined in:
lib/mongoid/selectable.rb

Overview

Provides behaviour for generating the selector for a specific document.

Since:

  • 4.0.0

Instance Method Summary collapse

Instance Method Details

#atomic_selectorHash

Get the atomic selector for the document. This is a hash in the simplest case { “_id” => id }, but can become more complex for embedded documents and documents that use a shard key.

Examples:

Get the document's atomic selector.

document.atomic_selector

Returns:

  • (Hash)

    The document's selector.

Since:

  • 1.0.0


20
21
22
# File 'lib/mongoid/selectable.rb', line 20

def atomic_selector
  @atomic_selector ||= { "_id" => _root._id }.merge!(shard_key_selector)
end