Sha256: 391d4fb7f3a9fb5e970d343b609b0482b1148f535c8669c4dd3fffb7da0e4b7a

Contents?: true

Size: 838 Bytes

Versions: 48

Compression:

Stored size: 838 Bytes

Contents

module Hyrax
  # Grants edit access for the supplied user for the members attached to a work
  class GrantEditToMembersJob < ApplicationJob
    queue_as Hyrax.config.ingest_queue_name

    # @param [ActiveFedora::Base] work - the work object
    # @param [String] user_key - the user to add
    def perform(work, user_key)
      # Iterate over ids because reifying objects is slow.
      file_set_ids(work).each do |file_set_id|
        # Call this synchronously, since we're already in a job
        GrantEditJob.perform_now(file_set_id, user_key)
      end
    end

    private

      # Filter the member ids and return only the FileSet ids (filter out child works)
      # @return [Array<String>] the file set ids
      def file_set_ids(work)
        ::FileSet.search_with_conditions(id: work.member_ids).map(&:id)
      end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.9.5 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.9.4 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.9.3 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.9.2 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.9.1 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.9.0 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.8.0 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.7.2 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.7.1 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.7.0 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.6.0 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-3.0.0.pre.rc1 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-3.0.0.pre.beta3 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.5.1 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.5.0 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-3.0.0.pre.beta2 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.4.1 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-3.0.0.pre.beta1 app/jobs/hyrax/grant_edit_to_members_job.rb
hyrax-2.4.0 app/jobs/hyrax/grant_edit_to_members_job.rb