Class: Hyrax::Transactions::Steps::SaveAccessControl

Inherits:
Object
  • Object
show all
Defined in:
lib/hyrax/transactions/steps/save_access_control.rb

Overview

Saves the Hyrax::AccessControlList for any resource with a ‘#permission_manager`. If `#permission_manager` is undefined, succeeds.

Instance Method Summary collapse

Instance Method Details

#call(obj, permissions_params: []) ⇒ Dry::Monads::Result

Parameters:

  • obj (Valkyrie::Resource)

Returns:

  • (Dry::Monads::Result)

Since:

  • 2.4.0



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hyrax/transactions/steps/save_access_control.rb', line 19

def call(obj, permissions_params: [])
  return Success(obj) unless obj.respond_to?(:permission_manager)

  acl = obj.permission_manager&.acl
  # Translate step args into Hyrax::Permission objects before saving
  Array(permissions_params).each do |param|
    permission = param_to_permission(obj, param)
    acl << permission if permission
  end

  acl&.save || (return Failure[:failed_to_save_acl, acl])

  Success(obj)
end