Module: Mongoid::Slug::Index
- Defined in:
- lib/mongoid/slug/index.rb
Class Method Summary collapse
-
.build_index(scope_key = nil, by_model_type = false) ⇒ Array(Hash, Hash)
The indexable fields and index options.
Class Method Details
.build_index(scope_key = nil, by_model_type = false) ⇒ Array(Hash, Hash)
Returns the indexable fields and index options.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mongoid/slug/index.rb', line 8 def self.build_index(scope_key = nil, by_model_type = false) fields = { _slugs: 1 } = {} fields.merge!(scope_key => 1) if scope_key if by_model_type fields.merge!(_type: 1) else .merge!(unique: true, sparse: true) end [fields, ] end |