Sha256: d25aa0f80c645189bc5f3e765bda61b53e296f742547e48a5ffd024bbd6a5455

Contents?: true

Size: 729 Bytes

Versions: 29

Compression:

Stored size: 729 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
      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

29 entries across 29 versions & 1 rubygems

Version Path
hyrax-2.6.0 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-3.0.0.pre.rc1 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-3.0.0.pre.beta3 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-2.5.1 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-2.5.0 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-3.0.0.pre.beta2 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-2.4.1 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-3.0.0.pre.beta1 lib/hyrax/transactions/steps/ensure_permission_template.rb
hyrax-2.4.0 lib/hyrax/transactions/steps/ensure_permission_template.rb