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

Note:

this stack, and the Actor classes it calls, is not used when Valkyrie models are defined by the application. in that context, this behavior is replaced by ‘Hyrax::Transactions::Container`.

Provides the Hyrax “Actor Stack” used during creation of Works when ActiveFedora models are used by the application

The “Actor Stack” consists of a series of objects (“Actors”), which implement #create, #update and #destroy. Each actor’s methods promise to call the same methods on the next actor in the series, and may do some work before (on the way down the stack) and/or after (on the way up) calling to the next actor.

The normal convention is to call an actor inheriting Actors::BaseActor at or near the bottom of the stack, to handle the create, update , or destroy action.

Returns:

  • (#create, #update)

    an actor that can create and update the work

See Also:



49
50
51
# File 'app/services/hyrax/curation_concern.rb', line 49

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)

See Also:



23
24
25
# File 'app/services/hyrax/curation_concern.rb', line 23

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



55
56
57
58
59
60
61
62
# File 'app/services/hyrax/curation_concern.rb', line 55

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



65
66
67
68
69
70
71
72
73
# File 'app/services/hyrax/curation_concern.rb', line 65

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