psu-libraries/psulib_blacklight

View on GitHub
app/components/external_links/hathi_link_component.rb

Summary

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

module ExternalLinks
  class HathiLinkComponent < HathiGoogleLinksComponent
    def search_item
      return nil if free_to_read?

      return "oclc/#{oclc}" if oclc.present?

      return "lccn/#{lccn}" if lccn.present?

      return "issn/#{issn}" if issn.present?

      nil
    end

    private

      def issn
        document[:document]['issn_ssm']&.first
      end
  end
end