Class: Hyrax::Transactions::Steps::ApplyPermissionTemplate

Inherits:
Object
  • Object
show all
Includes:
Dry::Transaction::Operation
Defined in:
lib/hyrax/transactions/steps/apply_permission_template.rb

Overview

A `dry-transcation` step that applies a permission template.

Since:

  • 2.4.0

Instance Method Summary collapse

Instance Method Details

#call(work) ⇒ Dry::Monads::Result

Parameters:

Returns:

  • (Dry::Monads::Result)

Since:

  • 2.4.0


16
17
18
19
20
21
22
23
24
25
# File 'lib/hyrax/transactions/steps/apply_permission_template.rb', line 16

def call(work)
  return Failure(:missing_permission) unless
    (template = work&.admin_set&.permission_template)

  Hyrax::PermissionTemplateApplicator.apply(template).to(model: work)

  Success(work)
rescue ActiveRecord::RecordNotFound => err
  Failure(err)
end