Module: MongoMapper::Plugins::Shardable

Extended by:
ActiveSupport::Concern
Included in:
Document
Defined in:
lib/mongo_mapper/plugins/shardable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#shard_key_filterObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mongo_mapper/plugins/shardable.rb', line 11

def shard_key_filter
  filter = {}
  shard_key_fields.each do |field|
    filter[field] = if new_record?
      send(field)
    else
      changed_attributes.key?(field) ? changed_attributes[field] : send(field)
    end
  end
  filter
end