Sha256: b3608a17eadf3b0254e35bd1b4a4dfbb4306d3db3235dca8a4c46d2b9e9b64c8

Contents?: true

Size: 974 Bytes

Versions: 1

Compression:

Stored size: 974 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)
          return if embargo_manager.embargo.embargo_release_date.blank?

          embargo_manager.deactivate!
          work.embargo = Hyrax.persister.save(resource: embargo_manager.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

1 entries across 1 versions & 1 rubygems

Version Path
hyrax-5.0.0.rc1 app/actors/hyrax/actors/embargo_actor.rb