Sha256: adc98029e9649a57e0d09ac55452a7e57963ef905fa385c8e5bef72757d52bc2

Contents?: true

Size: 937 Bytes

Versions: 48

Compression:

Stored size: 937 Bytes

Contents

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

48 entries across 48 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.9.5 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.9.4 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.9.3 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.9.2 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.9.1 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.9.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.8.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.7.2 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.7.1 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.7.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.6.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.0.0.pre.rc1 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.0.0.pre.beta3 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.5.1 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.5.0 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.0.0.pre.beta2 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.4.1 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-3.0.0.pre.beta1 app/actors/hyrax/actors/featured_work_actor.rb
hyrax-2.4.0 app/actors/hyrax/actors/featured_work_actor.rb