Module: Mongoid::Shardable
Overview
This module contains behavior for adding shard key fields to updates.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#shard_key_fields ⇒ Array<String>
Get the shard key fields.
-
#shard_key_selector ⇒ Hash
Get the document selector with the defined shard keys.
Instance Method Details
#shard_key_fields ⇒ Array<String>
Note:
Refactored from using delegate for class load performance.
Get the shard key fields.
51 52 53 |
# File 'lib/mongoid/shardable.rb', line 51 def shard_key_fields self.class.shard_key_fields end |
#shard_key_selector ⇒ Hash
Get the document selector with the defined shard keys.
63 64 65 66 67 68 69 |
# File 'lib/mongoid/shardable.rb', line 63 def shard_key_selector selector = {} shard_key_fields.each do |field| selector[field.to_s] = new_record? ? send(field) : attribute_was(field) end selector end |