Class: Hyrax::Transactions::Steps::ChangeDepositor

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

Overview

Add a given ‘::User` as the `#depositor` Move the previous value of that property to `#proxy_depositor`

If no user is given, simply passes as a ‘Success`.

Since:

  • 3.4.0

Defined Under Namespace

Classes: NullUser

Instance Method Summary collapse

Instance Method Details

#call(obj, user: NullUser.new, reset: false) ⇒ Dry::Monads::Result

Parameters:

  • obj (Hyrax::Work)
  • user (User) (defaults to: NullUser.new)

    the user that will “become” the depositor of the given work

Returns:

  • (Dry::Monads::Result)

Since:

  • 3.4.0



24
25
26
27
28
29
30
31
32
# File 'lib/hyrax/transactions/steps/change_depositor.rb', line 24

def call(obj, user: NullUser.new, reset: false)
  return Success(obj) unless user&.user_key

  obj = Hyrax::ChangeDepositorService.call(obj, user, reset)

  Success(obj)
rescue StandardError => err
  Failure([err.message, obj])
end