Sha256: 35d9198eccc7aade3f99b22602eec8abcd65f22a234b698a50cd58db4cc9ca33

Contents?: true

Size: 890 Bytes

Versions: 9

Compression:

Stored size: 890 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  module Workflow
    ##
    # This is a built in function for workflow, so that a workflow action can be created that
    # grants the creator the ability to view their work.
    module GrantReadToDepositor
      # @param [#read_users=, #read_users] target to which we are adding read_users
      #   for the depositor
      # @return void
      def self.call(target:, **)
        return true unless target.try(:depositor)

        model = target.try(:model) || target # get the model if target is a ChangeSet
        model.read_users += Array.wrap(target.depositor)
        model.try(:permission_manager)&.acl&.save

        # If there are a lot of members, granting access to each could take a
        # long time. Do this work in the background.
        GrantReadToMembersJob.perform_later(model, target.depositor)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/services/hyrax/workflow/grant_read_to_depositor.rb
hyrax-5.0.4 app/services/hyrax/workflow/grant_read_to_depositor.rb
hyrax-5.0.3 app/services/hyrax/workflow/grant_read_to_depositor.rb
hyrax-5.0.2 app/services/hyrax/workflow/grant_read_to_depositor.rb
hyrax-5.0.1 app/services/hyrax/workflow/grant_read_to_depositor.rb
hyrax-5.0.0 app/services/hyrax/workflow/grant_read_to_depositor.rb
hyrax-5.0.0.rc3 app/services/hyrax/workflow/grant_read_to_depositor.rb
hyrax-5.0.0.rc2 app/services/hyrax/workflow/grant_read_to_depositor.rb
hyrax-5.0.0.rc1 app/services/hyrax/workflow/grant_read_to_depositor.rb