Sha256: d094a44e323a1339dcff1815741a5357821296611a1a6de4aac0f0466a55c703

Contents?: true

Size: 1.48 KB

Versions: 16

Compression:

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

    ##
    # 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

16 entries across 16 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/lib/blacklight/abstract_repository.rb
blacklight-8.3.0 lib/blacklight/abstract_repository.rb
blacklight-8.2.2 lib/blacklight/abstract_repository.rb
blacklight-8.2.1 lib/blacklight/abstract_repository.rb
blacklight-8.2.0 lib/blacklight/abstract_repository.rb
blacklight-8.1.0 lib/blacklight/abstract_repository.rb
blacklight-8.0.1 lib/blacklight/abstract_repository.rb
blacklight-8.0.0 lib/blacklight/abstract_repository.rb
blacklight-8.0.0.beta8 lib/blacklight/abstract_repository.rb
blacklight-8.0.0.beta7 lib/blacklight/abstract_repository.rb
blacklight-8.0.0.beta6 lib/blacklight/abstract_repository.rb
blacklight-8.0.0.beta5 lib/blacklight/abstract_repository.rb
blacklight-8.0.0.beta4 lib/blacklight/abstract_repository.rb
blacklight-8.0.0.beta3 lib/blacklight/abstract_repository.rb
blacklight-8.0.0.beta2 lib/blacklight/abstract_repository.rb
blacklight-8.0.0.beta1 lib/blacklight/abstract_repository.rb