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



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

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)


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

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



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

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



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

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