Sha256: cfa17d5c7db9c45e0286ee1627ef4d222d21f83680d7bf591755203b61b7aa0e

Contents?: true

Size: 848 Bytes

Versions: 5

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

module Hyrax
  module Listeners
    ##
    # Reindexes resources when their ACLs are updated
    #
    # Hyrax's `Ability` behavior depends on the index being up-to-date as
    # concerns-their read/write users/groups, and visibility.
    class ActiveFedoraAclIndexListener
      ##
      # Re-index the resource for the updated ACL.
      #
      # @param event [Dry::Event]
      def on_object_acl_updated(event)
        return unless event[:result] == :success # do nothing on failure

        if Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter)
          Wings::ActiveFedoraConverter.convert(resource: event[:acl].resource).update_index
        else
          Hyrax.logger.info('Skipping ActiveFedora object reindex because the Wings adapter is not in use.')
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hyrax-3.1.0 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-3.0.2 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-3.0.1 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-3.0.0 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-3.0.0.pre.rc4 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb