Sha256: 598a634fad7a1dbe782495661fedb201be0f5eda9e3392f28bbd782a007cfb92

Contents?: true

Size: 821 Bytes

Versions: 16

Compression:

Stored size: 821 Bytes

Contents

# frozen_string_literal: true
require 'dry/monads'

module Hyrax
  module Transactions
    module Steps
      ##
      # Deletes the Hyrax::AccessControlList for any resource with a `#permission_manager`.
      # If `#permission_manager` is undefined, succeeds.
      #
      # @see https://dry-rb.org/gems/dry-monads/1.0/result/
      class DeleteAccessControl
        include Dry::Monads[:result]

        ##
        # @param [Valkyrie::Resource] obj
        #
        # @return [Dry::Monads::Result]
        def call(obj)
          return Success(obj) unless obj.respond_to?(:permission_manager)

          acl = obj.permission_manager&.acl
          return Success(obj) if acl.nil?

          acl.destroy || (return Failure[:failed_to_delete_acl, acl])

          Success(obj)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
hyrax-5.0.1 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-5.0.0 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-5.0.0.rc3 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-5.0.0.rc2 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-5.0.0.rc1 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-3.6.0 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-4.0.0 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-4.0.0.rc3 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-4.0.0.rc2 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-4.0.0.rc1 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-3.5.0 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-4.0.0.beta2 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-3.4.2 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-4.0.0.beta1 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-3.4.1 lib/hyrax/transactions/steps/delete_access_control.rb
hyrax-3.4.0 lib/hyrax/transactions/steps/delete_access_control.rb