Sha256: 1bbf55377e9e9fcc478bce1dd6cbffd3f9a385555615e1bb9aa509974f04fd81

Contents?: true

Size: 966 Bytes

Versions: 1

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true

module Hyrax
  module Listeners
    ##
    # Reindexes resources when their metadata is updated.
    #
    # @note This listener makes no attempt to avoid reindexing when no metadata
    #   has actually changed, or when real metadata changes won't impact the
    #   indexed data. We trust that published metadata update events represent
    #   actual changes to object metadata, and that the indexing adapter
    #   optimizes reasonably for actual index document contents.
    class MetadataIndexListener
      ##
      # Re-index the resource.
      #
      # @param event [Dry::Event]
      def on_object_metadata_updated(event)
        return Hyrax.index_adapter.save(resource: event[:object]) if
          event[:object].is_a?(Valkyrie::Resource)

        Hyrax.logger.info('Skipping object reindex because the object ' \
                          "#{event[:object]} was not a Valkyrie::Resource.")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hyrax-3.0.0.pre.rc4 app/services/hyrax/listeners/metadata_index_listener.rb