Class: Hyrax::Transactions::Steps::SaveWork Deprecated

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

Overview

Deprecated.

This is part of the legacy AF set of transaction steps for works. Transactions are not being used with AF works. This will be removed in 4.0.

A `dry-transaction` step that saves an input work.

Examples:

saving a work

step = Hyrax::Transactions::Steps::SaveWork.new
work = MyWork.new(title: ['Comet in Moominland'])

step.call(work) # => Success

handling error cases

step = Hyrax::Transactions::Steps::SaveWork.new
work = MyWork.new(title: [:invalid_title])

step.call(work).or { |err| puts err.messages }

See Also:

Since:

  • 2.4.0

Instance Method Summary collapse

Instance Method Details

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

Returns `Failure` if the work fails to save; `Success(input)`, otherwise.

Parameters:

Returns:

  • (Dry::Monads::Result)

    `Failure` if the work fails to save; `Success(input)`, otherwise.

Since:

  • 2.4.0


32
33
34
# File 'lib/hyrax/transactions/steps/save_work.rb', line 32

def call(work)
  work.save ? Success(work) : Failure(work.errors)
end