Class: Hyrax::Listeners::BatchNotificationListener

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

Overview

Listens for events related to batch activity and creates notifications

Instance Method Summary collapse

Instance Method Details

#on_batch_created(event) ⇒ void

This method returns an undefined value.

Notify requesting users of batch success/failure

Called when 'batch.created' event is published

Parameters:

  • event (Dry::Events::Event)

14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/hyrax/listeners/batch_notification_listener.rb', line 14

def on_batch_created(event)
  case event[:result]
  when :success
    Hyrax::BatchCreateSuccessService
      .new(event[:user])
      .call
  when :failure
    Hyrax::BatchCreateFailureService
      .new(event[:user], event[:messages])
      .call
  end
end