Module: Mongoid::Selectable
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
ActiveSupport::Concern
|
|
Defined in: | lib/mongoid/selectable.rb |
Overview
Provides behavior for generating the selector for a specific document.
Instance Method Summary
-
#atomic_selector ⇒ Hash
Get the atomic selector for the document.
-
#embedded_atomic_selector ⇒ Hash
private
Internal use only
Internal use only
Get the atomic selector for an embedded document.
-
#root_atomic_selector_in_db ⇒ Hash
private
Internal use only
Internal use only
Get the atomic selector that would match the existing version of the root document.
Instance Method Details
#atomic_selector ⇒ Hash
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.
# File 'lib/mongoid/selectable.rb', line 18
def atomic_selector ? : root_atomic_selector_in_db end
#embedded_atomic_selector ⇒ Hash (private)
This method is for internal use only.
Get the atomic selector for an embedded document.
# File 'lib/mongoid/selectable.rb', line 32
def if persisted? && _id_changed? _parent.atomic_selector else _parent.atomic_selector.merge("#{atomic_path}._id" => _id) end end
#root_atomic_selector_in_db ⇒ Hash (private)
This method is for internal use only.
Get the atomic selector that would match the existing version of the root document.
# File 'lib/mongoid/selectable.rb', line 46
def root_atomic_selector_in_db { "_id" => _id }.merge!(shard_key_selector_in_db) end