Class: Hyrax::Listeners::WorkflowListener

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

Overview

Listens for object lifecycle events that require workflow changes and manages workflow accordingly.

Instance Method Summary collapse

Instance Method Details

#factory#create

Note:

respects class attribute configuration at Actors::InitializeWorkflowActor.workflow_factory, but falls back on Workflow::WorkflowFactory to prepare for removal of Actors

Returns default: Workflow::WorkflowFactory.

Returns:


15
16
17
18
19
20
21
# File 'app/services/hyrax/listeners/workflow_listener.rb', line 15

def factory
  if defined?(Hyrax::Actors::InitializeWorkflowActor)
    Hyrax::Actors::InitializeWorkflowActor.workflow_factory
  else
    Hyrax::Workflow::WorkflowFactory
  end
end

#on_object_deposited(event) ⇒ Object

Parameters:

  • event (Dry::Event)

25
26
27
28
29
30
31
32
33
# File 'app/services/hyrax/listeners/workflow_listener.rb', line 25

def on_object_deposited(event)
  return Rails.logger.warn("Skipping workflow initialization for #{event[:object]}; no user is given\n\t#{event}") if
    event[:user].blank?

  factory.create(event[:object], {}, event[:user])
rescue Sipity::StateError, Sipity::ConversionError => err
  # don't error on known sipity error types; log instead
  Rails.logger.error(err)
end