Class: Hyrax::Transactions::Steps::SetUserAsCreator

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

Overview

Add a given ‘::User` as the `#creator` 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_creator.rb', line 21

def call(change_set, user: NullUser.new)
  change_set.creator = [user.user_key] if user.user_key

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