sul-dlss/dor-services-app

View on GitHub
app/services/indexing/indexers/default_object_rights_indexer.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

module Indexing
  module Indexers
    # Indexes the default object rights
    class DefaultObjectRightsIndexer
      attr_reader :cocina

      def initialize(cocina:, **)
        @cocina = cocina
      end

      # @return [Hash] the partial solr document for defaultObjectRights
      def to_solr
        return {} unless cocina.administrative.accessTemplate

        {
          'use_statement_ssim' => use_statement,
          'copyright_ssim' => copyright,
          'rights_descriptions_ssim' => 'dark',
          'default_rights_descriptions_ssim' => Cocina::Models::Builders::RightsDescriptionBuilder.build(cocina)
        }
      end

      private

      def use_statement
        cocina.administrative.accessTemplate.useAndReproductionStatement
      end

      def copyright
        cocina.administrative.accessTemplate.copyright
      end
    end
  end
end