Module: Hyrax::Workflow::GrantEditToDepositor

Defined in:
app/services/hyrax/workflow/grant_edit_to_depositor.rb

Overview

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.

Class Method Summary collapse

Class Method Details

.call(target:) ⇒ Object

Returns void.

Parameters:

  • target (#read_users=, #read_users)

    (likely an ActiveRecord::Base) to which we are adding edit_users for the depositor

Returns:

  • void



10
11
12
13
14
15
16
17
18
19
20
# File 'app/services/hyrax/workflow/grant_edit_to_depositor.rb', line 10

def self.call(target:, **)
  return true unless target.try(:depositor)

  model = target.try(:model) || target # get the model if target is a ChangeSet
  model.edit_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.
  GrantEditToMembersJob.perform_later(model, target.depositor)
end