Sha256: db1b0fb644daf1c384541e943645054d0212906dfb88b2cb05665f8b7e8c4ad9

Contents?: true

Size: 819 Bytes

Versions: 7

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  module Actors
    class LeaseActor
      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 lease, then clear the lease date, etc.
      # Saves the lease and the work
      def destroy
        case work
        when Valkyrie::Resource
          lease_manager = Hyrax::LeaseManager.new(resource: work)
          lease_manager.release && Hyrax::AccessControlList(work).save
          lease_manager.nullify
        else
          work.lease_visibility! # If the lease has lapsed, update the current visibility.
          work.deactivate_lease!
          work.lease.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/lease_actor.rb
hyrax-4.0.0 app/actors/hyrax/actors/lease_actor.rb
hyrax-4.0.0.rc3 app/actors/hyrax/actors/lease_actor.rb
hyrax-4.0.0.rc2 app/actors/hyrax/actors/lease_actor.rb
hyrax-4.0.0.rc1 app/actors/hyrax/actors/lease_actor.rb
hyrax-3.5.0 app/actors/hyrax/actors/lease_actor.rb
hyrax-4.0.0.beta2 app/actors/hyrax/actors/lease_actor.rb