Sha256: 7ac02e206e606e025923f686001cc18f4832bcf23ed5f7b98146574ff006fc3e
Contents?: true
Size: 662 Bytes
Versions: 3
Compression:
Stored size: 662 Bytes
Contents
module MongoMapper module Plugins module Shardable extend ActiveSupport::Concern included do class_attribute :shard_key_fields self.shard_key_fields = [] end 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 module ClassMethods def shard_key(*fields) self.shard_key_fields = fields.map(&:to_s).freeze end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongo_mapper-0.16.0 | lib/mongo_mapper/plugins/shardable.rb |
mongo_mapper-0.15.6 | lib/mongo_mapper/plugins/shardable.rb |
mongo_mapper-0.15.5 | lib/mongo_mapper/plugins/shardable.rb |