Class: Hyrax::Transactions::Steps::SetUserAsDepositor

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

Overview

Add a given ‘::User` as the `#depositor` via a ChangeSet.

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

Since:

  • 3.0.0

Defined Under Namespace

Classes: NullUser

Instance Method Summary collapse

Instance Method Details

#call(change_set, user: NullUser.new) ⇒ Dry::Monads::Result

Parameters:

Returns:

  • (Dry::Monads::Result)

Since:

  • 3.0.0



21
22
23
24
25
26
27
# File 'lib/hyrax/transactions/steps/set_user_as_depositor.rb', line 21

def call(change_set, user: NullUser.new)
  change_set.depositor = user.user_key if user.user_key

  Success(change_set)
rescue NoMethodError => err
  Failure([err.message, change_set])
end