Sha256: 8153dd67ef301fbbaf5e574ebb1cb841c2f03e0b568839afeaa8250b65ee62b0

Contents?: true

Size: 843 Bytes

Versions: 7

Compression:

Stored size: 843 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  module Actors
    class EmbargoActor
      attr_reader :work

      # @param [Hydra::Works::Work] work
      def initialize(work)
        @work = work
      end

      # Update the visibility of the work to match the correct state of the embargo, then clear the embargo date, etc.
      # Saves the embargo and the work
      def destroy
        case work
        when Valkyrie::Resource
          embargo_manager = Hyrax::EmbargoManager.new(resource: work)
          embargo_manager.release && Hyrax::AccessControlList(work).save
          embargo_manager.nullify
        else
          work.embargo_visibility! # If the embargo has lapsed, update the current visibility.
          work.deactivate_embargo!
          work.embargo.save!
          work.save!
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyrax-3.6.0 app/actors/hyrax/actors/embargo_actor.rb
hyrax-4.0.0 app/actors/hyrax/actors/embargo_actor.rb
hyrax-4.0.0.rc3 app/actors/hyrax/actors/embargo_actor.rb
hyrax-4.0.0.rc2 app/actors/hyrax/actors/embargo_actor.rb
hyrax-4.0.0.rc1 app/actors/hyrax/actors/embargo_actor.rb
hyrax-3.5.0 app/actors/hyrax/actors/embargo_actor.rb
hyrax-4.0.0.beta2 app/actors/hyrax/actors/embargo_actor.rb