Class: Hyrax::Actors::BaseActor

Inherits:
AbstractActor show all
Defined in:
app/actors/hyrax/actors/base_actor.rb

Overview

Defines the basic save/destroy and callback behavior, intended to run near the bottom of the actor stack.

Examples:

Defining a base actor for a custom work type

module Hyrax
  module Actors
    class MyWorkActor < Hyrax::Actors::BaseActor; end
  end
end

See Also:

  • Hyrax::Actor::AbstractActor

Instance Attribute Summary

Attributes inherited from AbstractActor

#next_actor

Instance Method Summary collapse

Methods inherited from AbstractActor

#initialize

Constructor Details

This class inherits a constructor from Hyrax::Actors::AbstractActor

Instance Method Details

#create(env) ⇒ Boolean

Returns true if create was successful.

Parameters:

Returns:

  • (Boolean)

    true if create was successful



18
19
20
21
22
# File 'app/actors/hyrax/actors/base_actor.rb', line 18

def create(env)
  apply_creation_data_to_curation_concern(env)
  apply_save_data_to_curation_concern(env)
  save(env) && next_actor.create(env) && run_callbacks(:after_create_concern, env)
end

#destroy(env) ⇒ Boolean

Returns true if destroy was successful.

Parameters:

Returns:

  • (Boolean)

    true if destroy was successful



34
35
36
37
38
39
40
41
# File 'app/actors/hyrax/actors/base_actor.rb', line 34

def destroy(env)
  env.curation_concern.in_collection_ids.each do |id|
    destination_collection = ::Collection.find(id)
    destination_collection.members.delete(env.curation_concern)
    destination_collection.update_index
  end
  env.curation_concern.destroy
end

#update(env) ⇒ Boolean

Returns true if update was successful.

Parameters:

Returns:

  • (Boolean)

    true if update was successful



26
27
28
29
30
# File 'app/actors/hyrax/actors/base_actor.rb', line 26

def update(env)
  apply_update_data_to_curation_concern(env)
  apply_save_data_to_curation_concern(env)
  next_actor.update(env) && save(env) && run_callbacks(:after_update_metadata, env)
end