Class: Hyrax::Transactions::CreateWork Deprecated

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

Overview

Deprecated.

Development on Dry::Transaction has been discontinued, we’re removing existing transactions and replacing them with Dry::Monad-based valkyrie versions.

TODO:

add collection membership handling (@see CollectionsMembershipActor)

TODO:

set depositor (@see BaseActor)

TODO:

initialize workflow after save (@see BaseActor)

TODO:

add to parent works post-save (see: ‘AddToWorkActor`)

TODO:

attach files (see: ‘CreateWithFilesActor`, `CreateWithRemoteFilesActor`

TODO:

validate PermissionTemplate against visibility, lease, and embargo (see: ‘InterpretVisibilityActor`)

TODO:

add locking/transactionality. Just do better than the Actor Stack

TODO:

add support for proxy deposit (see: TransferRequestActor)

Note:

This is an experimental replacement for the actor stack’s ‘#create` stack. In time, we hope this will have feature parity with that stack, along with improved architecture, error handling, readability, and customizability. While this develops, please provide feedback.

A transaction for creating a Work ready for use in Hyrax. Handles ensuring admin sets and permission templates are present, and setting system managed dates prior to save.

Examples:

Creating a work transactionally

work   = MyWork.new(title: ['Comet in Moominland'])
result = Hyrax::Transactions::CreateWork.call(work)
result.success? => true

Handling errors with procedural style

work   = MyWork.new # invalid work (no title)
result = Hyrax::Transactions::CreateWork.call(work)
result.success? => false

result.failure # => failure description or object

Handling errors with ‘#or`

work   = MyWork.new # invalid work (no title)

Hyrax::Transactions::CreateWork
  .call(work)
  .or { |error| handle_error(error) }

See Also:

Since:

  • 2.4.0