Sha256: 93205d13c8e7d815c2634ecf152bc82f12223edfaf5d10bc372a55bb9289c131

Contents?: true

Size: 902 Bytes

Versions: 5

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  module Transactions
    module Steps
      ##
      # A `dry-transaction` step that ensures the input `work` has a permission
      # template.
      #
      # @since 2.4.0
      # @deprecated This is part of the legacy AF set of transaction steps for works.
      #   Transactions are not being used with AF works.  This will be removed in 4.0.
      class EnsurePermissionTemplate
        include Dry::Transaction::Operation

        ##
        # @param [Hyrax::WorkBehavior] work
        #
        # @return [Dry::Monads::Result] `Failure` if there is no
        #   `PermissionTemplate` for the input; `Success(input)`, otherwise.
        def call(work)
          return Failure(:no_permission_template) unless
            Hyrax::PermissionTemplate.find_by(source_id: work.admin_set&.id)

          Success(work)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hyrax-3.6.0 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-3.5.0 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-3.4.2 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-3.4.1 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-3.4.0 lib/hyrax/transactions/steps/ensure_permission_template.rb