Sha256: 929d4e85cbb5b443a5b9d7804e8cf997721ae4e82b9979d6ea50ec3a36132da7

Contents?: true

Size: 860 Bytes

Versions: 25

Compression:

Stored size: 860 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  module CustomQueries
    # @example
    #   Hyrax.custom_queries.find_access_control_for(resource: resource)
    class FindAccessControl
      def self.queries
        [:find_access_control_for]
      end

      def initialize(query_service:)
        @query_service = query_service
      end

      attr_reader :query_service
      delegate :resource_factory, to: :query_service

      def find_access_control_for(resource:)
        query_service
          .find_inverse_references_by(resource: resource, property: :access_to)
          .find { |r| r.is_a?(Hyrax::AccessControl) } ||
          raise(Valkyrie::Persistence::ObjectNotFoundError)
      rescue ArgumentError # some adapters raise ArgumentError for missing resources
        raise(Valkyrie::Persistence::ObjectNotFoundError)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-5.0.0 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-5.0.0.rc3 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-5.0.0.rc2 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-5.0.0.rc1 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-3.6.0 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-4.0.0 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-4.0.0.rc3 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-4.0.0.rc2 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-4.0.0.rc1 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-3.5.0 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-4.0.0.beta2 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-3.4.2 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-4.0.0.beta1 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-3.4.1 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-3.4.0 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-3.3.0 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-3.2.0 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-3.1.0 app/services/hyrax/custom_queries/find_access_control.rb
hyrax-3.0.2 app/services/hyrax/custom_queries/find_access_control.rb