Sha256: e5f78d5d19e0002912684e47a123ad007da682a91c8586d8c8139ce5a0247c4d

Contents?: true

Size: 860 Bytes

Versions: 6

Compression:

Stored size: 860 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 alter it.
    module GrantEditToDepositor
      # @param [#read_users=, #read_users] target (likely an ActiveRecord::Base) to which we are adding edit_users for the depositor
      # @return void
      def self.call(target:, **)
        return true unless target.try(:depositor)
        target.edit_users = target.edit_users.to_a + Array.wrap(target.depositor) # += works in Ruby 2.6+
        target.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.
        GrantEditToMembersJob.perform_later(target, target.depositor)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hyrax-3.1.0 app/services/hyrax/workflow/grant_edit_to_depositor.rb
hyrax-3.0.2 app/services/hyrax/workflow/grant_edit_to_depositor.rb
hyrax-3.0.1 app/services/hyrax/workflow/grant_edit_to_depositor.rb
hyrax-3.0.0 app/services/hyrax/workflow/grant_edit_to_depositor.rb
hyrax-3.0.0.pre.rc4 app/services/hyrax/workflow/grant_edit_to_depositor.rb
hyrax-3.0.0.pre.rc3 app/services/hyrax/workflow/grant_edit_to_depositor.rb