Sha256: 1e62936d1e9ad4a490dcaa88e28c2201e39ccbdd07acdbd6999b80485c18f657

Contents?: true

Size: 848 Bytes

Versions: 5

Compression:

Stored size: 848 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
          Hyrax::EmbargoManager.deactivate_embargo_for(resource: work) &&
            Hyrax.persister.save(resource: work.embargo) &&
            Hyrax::AccessControlList(work).save
        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

5 entries across 5 versions & 1 rubygems

Version Path
hyrax-5.0.2 app/actors/hyrax/actors/embargo_actor.rb
hyrax-5.0.1 app/actors/hyrax/actors/embargo_actor.rb
hyrax-5.0.0 app/actors/hyrax/actors/embargo_actor.rb
hyrax-5.0.0.rc3 app/actors/hyrax/actors/embargo_actor.rb
hyrax-5.0.0.rc2 app/actors/hyrax/actors/embargo_actor.rb