Sha256: 1e445d696323f6d3691841f070770387cab9d505d9a596a4bc37707030934b17

Contents?: true

Size: 1.64 KB

Versions: 6

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module Blacklight
  # Base class for Blacklight repository adapters
  class AbstractRepository
    # @return [Blacklight::Configuration]
    attr_accessor :blacklight_config

    # Direct writer for the connection
    attr_writer :connection

    # (Note: ActiveSupport::Benchmarkable requires a logger method)
    # @return [Logger]
    attr_writer :logger

    include ActiveSupport::Benchmarkable

    ##
    # @param [Blacklight::Configuration] blacklight_config
    def initialize blacklight_config
      @blacklight_config = blacklight_config
    end

    ##
    # The raw data store connection
    def connection
      @connection ||= build_connection
    end

    ##
    # Find a single document result by a known id
    # @param [String] _id document's unique key value
    # @param [Hash] _params additional query parameters
    def find(_id, _params = {})
      raise NotImplementedError
    end

    # Find multiple documents by their ids
    # @param [Hash] _params query parameters
    def find_many(params, **kwargs)
      search(params, **kwargs)
    end

    ##
    # Execute a search query against a search index
    # @param [Hash] _params query parameters
    def search(_params = {})
      raise NotImplementedError
    end

    # Query the fields that exist from the index
    # @return [Hash]
    def reflect_fields
      raise NotImplementedError
    end

    ##
    # Is the repository in a working state?
    def ping
      raise NotImplementedError
    end

    private

    def connection_config
      blacklight_config.connection_config
    end

    def logger
      @logger ||= Blacklight.logger
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blacklight-8.7.0 lib/blacklight/abstract_repository.rb
blacklight-8.6.1 lib/blacklight/abstract_repository.rb
blacklight-8.6.0 lib/blacklight/abstract_repository.rb
blacklight-8.5.1 lib/blacklight/abstract_repository.rb
blacklight-8.5.0 lib/blacklight/abstract_repository.rb
blacklight-8.4.0 lib/blacklight/abstract_repository.rb