Sha256: 465fff470950b49487d2d50671ded47d45a73f570f36ea8e79be5bc62a8f2d77

Contents?: true

Size: 1.85 KB

Versions: 25

Compression:

Stored size: 1.85 KB

Contents

module Qa::Authorities
  module LinkedData
    # A wrapper around configured linked data authorities for use with questioning_authority.  The search and find methods
    # can be called directly from an instance of this class.  The Qa::LinkedDataTermsController uses these methods to provide
    # a URL based API for searching and term retrieval.
    #
    # @see Qa::Authorities::LinkedData::SearchQuery#search
    # @see Qa::Authorities::LinkedData::FindTerm#find
    # @see Qa::LinkedDataTermsController#search
    # @see Qa::LinkedDataTermsController#show
    # @see Qa::Authorities::LinkedData::Config
    class GenericAuthority < Base
      attr_reader :authority_config
      private :authority_config

      delegate :supports_term?, :term_subauthorities?, :term_subauthority?,
               :term_id_expects_uri?, :term_id_expects_id?, to: :term_config

      delegate :supports_search?, to: :search_config
      delegate :subauthority?, :subauthorities?, to: :search_config, prefix: 'search'

      def initialize(auth_name)
        @authority_config = Qa::Authorities::LinkedData::Config.new(auth_name)
      end

      def reload_authorities
        @authorities_service.load_authorities
      end

      def authorities_service
        @authorities_service ||= Qa::LinkedData::AuthorityService
      end

      def search_service
        @search_service ||= Qa::Authorities::LinkedData::SearchQuery.new(search_config)
      end

      def item_service
        @item_service ||= Qa::Authorities::LinkedData::FindTerm.new(term_config)
      end

      delegate :search, to: :search_service
      delegate :find, to: :item_service
      delegate :load_authorities, :authority_names, to: :authorities_service

      private

        def search_config
          authority_config.search
        end

        def term_config
          authority_config.term
        end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
qa-4.1.0 lib/qa/authorities/linked_data/generic_authority.rb
qa-4.0.0 lib/qa/authorities/linked_data/generic_authority.rb
qa-4.0.0.rc3 lib/qa/authorities/linked_data/generic_authority.rb
qa-4.0.0.rc2 lib/qa/authorities/linked_data/generic_authority.rb
qa-4.0.0.rc1 lib/qa/authorities/linked_data/generic_authority.rb