Sha256: 92fc536fd663e6c6ea144a5ab847d06ea7cd59a37ca78441292577d5adf8f64a
Contents?: true
Size: 934 Bytes
Versions: 3
Compression:
Stored size: 934 Bytes
Contents
# frozen_string_literal: true require 'dry/monads' module Hyrax module Transactions module Steps ## # Add a given `::User` as the `#creator` via a ChangeSet. # # If no user is given, simply passes as a `Success`. # # @since 3.0.0 class SetUserAsCreator 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.creator = [user.user_key] if user.user_key Success(change_set) rescue NoMethodError => err Failure.new([err.message, change_set], err.backtrace.first) end ## # @api private class NullUser ## # @return [nil] def user_key nil end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems