Sha256: 0c1e658061ce51c4eadd6c8ad5977612c71f03924621e6c40bc72b4cec851cac

Contents?: true

Size: 874 Bytes

Versions: 21

Compression:

Stored size: 874 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

21 entries across 21 versions & 2 rubygems

Version Path
blacklight-8.6.1 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.6.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.5.1 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.5.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.4.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/app/models/concerns/blacklight/suggest/response.rb
blacklight-8.3.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.2.2 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.2.1 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.2.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.1.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.0.1 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.0.0 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.0.0.beta8 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.0.0.beta7 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.0.0.beta6 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.0.0.beta5 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.0.0.beta4 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.0.0.beta3 app/models/concerns/blacklight/suggest/response.rb
blacklight-8.0.0.beta2 app/models/concerns/blacklight/suggest/response.rb