Sha256: 9d65ab2f6a2b68bd5828fa9bb746998d6eea517f2598f84173f24e3ab2f7b6b5

Contents?: true

Size: 983 Bytes

Versions: 29

Compression:

Stored size: 983 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  module CustomQueries
    class FindManyByAlternateIds
      # Use:
      #   Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: ids)

      def self.queries
        [:find_many_by_alternate_ids]
      end

      attr_reader :query_service

      def initialize(query_service:)
        @query_service = query_service
      end

      # implements a combination of two Valkyrie queries:
      # => find_many_by_ids & find_by_alternate_identifier
      #
      # @param alternate_ids [Enumerator<#to_s>] list of ids
      # @return [Enumerable<Valkyrie::Resource>, Enumerable<ActiveFedora::Base>]
      def find_many_by_alternate_ids(alternate_ids:)
        return enum_for(:find_many_by_alternate_ids, alternate_ids: alternate_ids) unless
          block_given?

        alternate_ids.uniq do |id|
          yield query_service.find_by_alternate_identifier(alternate_identifier: id.to_s)
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-5.0.4 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-5.0.3 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-5.0.2 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-5.0.1 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-5.0.0 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-5.0.0.rc3 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-5.0.0.rc2 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-5.0.0.rc1 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-3.6.0 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-4.0.0 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-4.0.0.rc3 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-4.0.0.rc2 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-4.0.0.rc1 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-3.5.0 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-4.0.0.beta2 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-3.4.2 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-4.0.0.beta1 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-3.4.1 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
hyrax-3.4.0 app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb