Sha256: 2d2eaf5ee326d1d17b64216f008533a011639b26935fc89cd9cf7790abb78563

Contents?: true

Size: 953 Bytes

Versions: 25

Compression:

Stored size: 953 Bytes

Contents

# frozen_string_literal: true

module Hyrax
  module Actors
    # Removes featured works if the work is deleted or becomes private
    class FeaturedWorkActor < Hyrax::Actors::AbstractActor
      # @param [Hyrax::Actors::Environment] env
      # @return [Boolean] true if destroy was successful
      def destroy(env)
        cleanup_featured_works(env.curation_concern)
        next_actor.destroy(env)
      end

      # @param [Hyrax::Actors::Environment] env
      # @return [Boolean] true if update was successful
      def update(env)
        check_featureability(env.curation_concern)
        next_actor.update(env)
      end

      private

      def cleanup_featured_works(curation_concern)
        FeaturedWork.where(work_id: curation_concern.id).destroy_all
      end

      def check_featureability(curation_concern)
        return unless curation_concern.private?
        cleanup_featured_works(curation_concern)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-5.0.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-5.0.0.rc3 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-5.0.0.rc2 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-5.0.0.rc1 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.6.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-4.0.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-4.0.0.rc3 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-4.0.0.rc2 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-4.0.0.rc1 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.5.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-4.0.0.beta2 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.4.2 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-4.0.0.beta1 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.4.1 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.4.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.3.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.2.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.1.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.0.2 app/actors/hyrax/actors/featured_work_actor.rb