Module: Mongoid::Slug::IndexBuilder

Extended by:
IndexBuilder
Included in:
IndexBuilder
Defined in:
lib/mongoid/slug/index_builder.rb

Instance Method Summary collapse

Instance Method Details

#build_indexes(doc, scope_key = nil, by_model_type = false, locales = nil) ⇒ Array(Hash, Hash)

Creates indexes on a document for a given slug scope

Parameters:

  • doc (Mongoid::Document)

    The document on which to create the index(es)

  • scope_key (String or Symbol) (defaults to: nil)

    The optional scope key for the index(es)

  • by_model_type (Boolean) (defaults to: false)

    Whether or not to use single table inheritance

  • localize (Boolean or Array)

    The locale for localized index field

Returns:

  • (Array(Hash, Hash))

    the indexable fields and index options.



16
17
18
19
20
21
22
# File 'lib/mongoid/slug/index_builder.rb', line 16

def build_indexes(doc, scope_key = nil, by_model_type = false, locales = nil)
  if locales.is_a?(Array)
    locales.each { |locale| build_index(doc, scope_key, by_model_type, locale) }
  else
    build_index(doc, scope_key, by_model_type, locales)
  end
end