Class: Hyrax::Listeners::ObjectLifecycleListener
- Inherits:
-
Object
- Object
- Hyrax::Listeners::ObjectLifecycleListener
- Defined in:
- app/services/hyrax/listeners/object_lifecycle_listener.rb
Overview
Listens for events related to the PCDM Object lifecycles.
Instance Method Summary collapse
-
#on_object_deleted(event) ⇒ void
Called when ‘object.deleted’ event is published.
-
#on_object_deposited(event) ⇒ void
Called when ‘object.deposited’ event is published.
-
#on_object_metadata_updated(event) ⇒ void
Called when ‘object.metadata.updated’ event is published.
Instance Method Details
#on_object_deleted(event) ⇒ void
This method returns an undefined value.
Called when ‘object.deleted’ event is published
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
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
32 33 34 |
# File 'app/services/hyrax/listeners/object_lifecycle_listener.rb', line 32 def (event) ContentUpdateEventJob.perform_later(event[:object], event[:user]) end |