Class: Hyrax::Listeners::ObjectLifecycleListener

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/listeners/object_lifecycle_listener.rb

Overview

Listens for events related to the PCDM Object lifecycles.

Instance Method Summary collapse

Instance Method Details

#on_object_deleted(event) ⇒ void

This method returns an undefined value.

Called when ‘object.deleted’ event is published

Parameters:

  • event (Dry::Events::Event)


12
13
14
15
16
17
18
# File 'app/services/hyrax/listeners/object_lifecycle_listener.rb', line 12

def on_object_deleted(event)
  # Accessing a non-existent key on a Dry::Events::Event will raise a KeyError; hence
  # we cast the event to a hash
  event = event.to_h
  object_id = event[:object]&.id || event[:id]
  ContentDeleteEventJob.perform_later(object_id.to_s, event[:user])
end

#on_object_deposited(event) ⇒ void

This method returns an undefined value.

Called when ‘object.deposited’ event is published

Parameters:

  • event (Dry::Events::Event)


24
25
26
# File 'app/services/hyrax/listeners/object_lifecycle_listener.rb', line 24

def on_object_deposited(event)
  ContentDepositEventJob.perform_later(event[:object], event[:user])
end

#on_object_metadata_updated(event) ⇒ void

This method returns an undefined value.

Called when ‘object.metadata.updated’ event is published

Parameters:

  • event (Dry::Events::Event)


32
33
34
# File 'app/services/hyrax/listeners/object_lifecycle_listener.rb', line 32

def (event)
  ContentUpdateEventJob.perform_later(event[:object], event[:user])
end