Sha256: a9679a89acb3ba52c49b28681e9ac25201dd200d633a8c9627136125081515c0
Contents?: true
Size: 913 Bytes
Versions: 25
Compression:
Stored size: 913 Bytes
Contents
# frozen_string_literal: true require 'dry/monads' module Hyrax module Transactions module Steps ## # Add a given `::User` as the `#depositor` via a ChangeSet. # # If no user is given, simply passes as a `Success`. # # @since 3.0.0 class SetUserAsDepositor include Dry::Monads[:result] ## # @param [Hyrax::ChangeSet] change_set # @param [#user_key] user # # @return [Dry::Monads::Result] 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 ## # @api private class NullUser ## # @return [nil] def user_key nil end end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems