Sha256: 048737dd495fdbecd54ab05e1ed67bc56ef64dfa646cd0ead0ecc460f091083e

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

# The Searchable module can be included onto classes that need to initialize a SearchService.
# There are three dependencies you must provide on the including class. Typically these
# would be provided by Blacklight::Controller
#  1. search_state
#  2. blacklight_config
#  3. search_service_class
#
# Additionally, the including class may override the search_service_context method to provide
# further context to the SearchService. For example you could override this to provide the
# currently signed in user.
module Blacklight::Searchable
  # @return [Blacklight::SearchService]
  def search_service
    search_service_class.new(config: blacklight_config, user_params: search_state.to_h, **search_service_context)
  end

  # @return [Hash] a hash of context information to pass through to the search service
  def search_service_context
    {}
  end

  # @return [Blacklight::SuggestSearch]
  def suggestions_service
    Blacklight::SuggestSearch.new(params, search_service.repository).suggestions
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-7.12.1 app/controllers/concerns/blacklight/searchable.rb
blacklight-7.12.0 app/controllers/concerns/blacklight/searchable.rb
blacklight-7.11.1 app/controllers/concerns/blacklight/searchable.rb