Class: Hyrax::Transactions::Steps::EnsurePermissionTemplate

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

Overview

A `dry-transaction` step that ensures the input `work` has a permission template.

Since:

  • 2.4.0

Instance Method Summary collapse

Instance Method Details

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

Returns `Failure` if there is no `PermissionTemplate` for the input; `Success(input)`, otherwise.

Parameters:

Returns:

  • (Dry::Monads::Result)

    `Failure` if there is no `PermissionTemplate` for the input; `Success(input)`, otherwise.

Since:

  • 2.4.0


18
19
20
21
22
23
# File 'lib/hyrax/transactions/steps/ensure_permission_template.rb', line 18

def call(work)
  return Failure(:no_permission_template) unless
    Hyrax::PermissionTemplate.find_by(source_id: work.admin_set&.id)

  Success(work)
end