Sha256: 76d55194d5e5a90c9206dd2c11bffa4e449cfe818a0d1de5565a304eef117b2a
Contents?: true
Size: 1.13 KB
Versions: 23
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Hyrax module CustomQueries ## # @see https://github.com/samvera/valkyrie/wiki/Queries#custom-queries class FindIdsByModel def self.queries [:find_ids_by_model] end def initialize(query_service:) @query_service = query_service end attr_reader :query_service delegate :resource_factory, to: :query_service ## # @note this is an unoptimized default implementation of this custom # query. it's Hyrax's policy to provide such implementations of custom # queries in use for cross-compatibility of Valkyrie query services. # it's advisable to provide an optimized query for the specific adapter. # # @param model [Class] # @param ids [Enumerable<#to_s>, Symbol] # # @return [Enumerable<Valkyrie::ID>] def find_ids_by_model(model:, ids: :all) return query_service.find_all_of_model(model: model).map(&:id) if ids == :all query_service.find_many_by_ids(ids: ids).select do |resource| resource.is_a?(model) end.map(&:id) end end end end
Version data entries
23 entries across 23 versions & 1 rubygems