Sha256: 42e37219372e1a970849bfb80335c7e378cf186e0eebe4b19d9e2c34ec1c924a

Contents?: true

Size: 873 Bytes

Versions: 49

Compression:

Stored size: 873 Bytes

Contents

# frozen_string_literal: true
module Blacklight
  module Suggest
    class Response
      attr_reader :response, :request_params, :suggest_path, :suggester_name

      ##
      # Creates a suggest response
      # @param [RSolr::HashWithResponse] response
      # @param [Hash] request_params
      # @param [String] suggest_path
      # @param [String] suggester_name
      def initialize(response, request_params, suggest_path, suggester_name)
        @response = response
        @request_params = request_params
        @suggest_path = suggest_path
        @suggester_name = suggester_name
      end

      ##
      # Trys the suggester response to return suggestions if they are
      # present
      # @return [Array]
      def suggestions
        (response.dig(suggest_path, suggester_name, request_params[:q], 'suggestions') || []).uniq
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 2 rubygems

Version Path
blacklight-7.40.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.39.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.38.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/models/concerns/blacklight/suggest/response.rb
blacklight-7.37.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.36.2 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.36.1 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.36.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.35.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.34.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.33.1 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.33.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.32.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.31.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.30.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.29.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.28.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.27.1 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.27.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-7.26.1 app/models/concerns/blacklight/suggest/response.rb