Sha256: 9e2f4dd6cae67a9b6988ee975bc06f1efc95a40af8cfc33032c37a354fe4eb05
Contents?: true
Size: 1.35 KB
Versions: 4
Compression:
Stored size: 1.35 KB
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) log_non_resource(event) && return unless event[:object].is_a?(Valkyrie::Resource) Hyrax.index_adapter.save(resource: event[:object]) end ## # Remove the resource from the index. # # @param event [Dry::Event] def on_object_deleted(event) log_non_resource(event.payload) && return unless event.payload[:object].is_a?(Valkyrie::Resource) Hyrax.index_adapter.delete(resource: event[:object]) end private def log_non_resource(event) Hyrax.logger.info('Skipping object reindex because the object ' \ "#{event[:object]} was not a Valkyrie::Resource.") end end end end
Version data entries
4 entries across 4 versions & 1 rubygems