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


19
20
21
22
23
24
25
26
# File 'app/actors/hyrax/actors/base_actor.rb', line 19

def create(env)
  apply_creation_data_to_curation_concern(env)
  apply_save_data_to_curation_concern(env)

  save(env, use_valkyrie: Hyrax.config.use_valkyrie?) &&
    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


38
39
40
41
42
43
44
45
# File 'app/actors/hyrax/actors/base_actor.rb', line 38

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


30
31
32
33
34
# File 'app/actors/hyrax/actors/base_actor.rb', line 30

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