Class: Hyrax::CurationConcern
- Inherits:
-
Object
- Object
- Hyrax::CurationConcern
- Defined in:
- app/services/hyrax/curation_concern.rb
Class Method Summary collapse
-
.actor ⇒ #create, #update
Provides the Hyrax “Actor Stack” used during creation of Works when
ActiveFedora
models are used by the application. -
.actor_factory ⇒ ActionDispatch::MiddlewareStack
The actor middleware stack can be customized like so: # Adding a new middleware Hyrax::CurationConcern.actor_factory.use MyCustomActor.
-
.file_set_create_actor ⇒ #create
NOTE: I don’t know why this middleware doesn’t use the BaseActor - Justin.
-
.file_set_update_actor ⇒ #update
An actor for updating the FileSet.
Class Method Details
.actor ⇒ #create, #update
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.
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_factory ⇒ ActionDispatch::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.
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
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.
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 |