Class: Hyrax::CurationConcern

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

Class Method Summary collapse

Class Method Details

.actor#create, #update

A consumer of this method can inject a different factory into this class in order to change the behavior of this method.

Returns:

  • (#create, #update)

    an actor that can create and update the work


27
28
29
# File 'app/services/hyrax/curation_concern.rb', line 27

def self.actor
  @work_middleware_stack ||= actor_factory.build(Actors::Terminator.new)
end

.actor_factoryActionDispatch::MiddlewareStack

The actor middleware stack can be customized like so:

# Adding a new middleware
Hyrax::CurationConcern.actor_factory.use MyCustomActor

# Inserting a new middleware at a specific position
Hyrax::CurationConcern.actor_factory.insert_after Hyrax::Actors::CreateWithRemoteFilesActor, MyCustomActor

# Removing a middleware
Hyrax::CurationConcern.actor_factory.delete Hyrax::Actors::CreateWithRemoteFilesActor

# Replace one middleware with another
Hyrax::CurationConcern.actor_factory.swap Hyrax::Actors::CreateWithRemoteFilesActor, MyCustomActor

You can customize the actor stack, so long as you do so before the actor is used. Once it is used, it becomes immutable.

Returns:

  • (ActionDispatch::MiddlewareStack)

20
21
22
# File 'app/services/hyrax/curation_concern.rb', line 20

def self.actor_factory
  @actor_factory ||= Hyrax::DefaultMiddlewareStack.build_stack
end

.file_set_create_actor#create

NOTE: I don't know why this middleware doesn't use the BaseActor - Justin

Returns:

  • (#create)

    an actor for creating the FileSet


33
34
35
36
37
38
39
40
# File 'app/services/hyrax/curation_concern.rb', line 33

def self.file_set_create_actor
  @file_set_create_actor ||= begin
    stack = ActionDispatch::MiddlewareStack.new.tap do |middleware|
      middleware.use Actors::InterpretVisibilityActor
    end
    stack.build(Actors::Terminator.new)
  end
end

.file_set_update_actor#update

Returns an actor for updating the FileSet.

Returns:

  • (#update)

    an actor for updating the FileSet


43
44
45
46
47
48
49
50
51
# File 'app/services/hyrax/curation_concern.rb', line 43

def self.file_set_update_actor
  @file_set_update_actor ||= begin
    stack = ActionDispatch::MiddlewareStack.new.tap do |middleware|
      middleware.use Actors::InterpretVisibilityActor
      middleware.use Actors::BaseActor
    end
    stack.build(Actors::Terminator.new)
  end
end