Module: Spree::SearchProvider

Defined in:
app/models/spree/search_provider.rb,
app/models/spree/search_provider/base.rb,
app/jobs/spree/search_provider/index_job.rb,
app/jobs/spree/search_provider/remove_job.rb,
app/models/spree/search_provider/database.rb,
app/models/spree/search_provider/search_result.rb,
app/models/spree/search_provider/filters_result.rb,
app/services/spree/search_provider/custom_field_schema.rb

Defined Under Namespace

Classes: Base, CustomFieldSchema, Database, FiltersResult, IndexJob, RemoveJob, SearchResult

Constant Summary collapse

MOVED_TO_SPREE_MEILISEARCH =

Meilisearch moved out of core into the spree_meilisearch gem at 6.0, taking the document presenter with it. Applications configure the provider by class name, so resolve the old constants to the new ones until 6.3 rather than failing at boot with a bare NameError.

{
  Meilisearch: 'SpreeMeilisearch::SearchProvider',
  ProductPresenter: 'SpreeMeilisearch::ProductPresenter'
}.freeze

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/spree/search_provider.rb', line 12

def self.const_missing(name)
  replacement = MOVED_TO_SPREE_MEILISEARCH[name]
  return super if replacement.nil?

  unless Object.const_defined?(replacement)
    raise NameError, "Spree::SearchProvider::#{name} moved to #{replacement} in Spree 6.0. " \
                     "Add `gem 'spree_meilisearch'` to your Gemfile."
  end

  if defined?(Spree::Deprecation)
    Spree::Deprecation.warn(
      "Spree::SearchProvider::#{name} is deprecated and will be removed in Spree 6.3. " \
      "Use #{replacement} instead."
    )
  end

  replacement.constantize
end