Sha256: de8aee87aa484788f82671f44730817df47e5b1581e599c22722f40d1774ede2

Contents?: true

Size: 826 Bytes

Versions: 7

Compression:

Stored size: 826 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
          Hyrax::LeaseManager.deactivate_lease_for(resource: work) &&
            Hyrax.persister.save(resource: work.lease) &&
            Hyrax::AccessControlList(work).save
        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-5.1.0.pre.beta1 app/actors/hyrax/actors/lease_actor.rb
hyrax-5.0.4 app/actors/hyrax/actors/lease_actor.rb
hyrax-5.0.3 app/actors/hyrax/actors/lease_actor.rb
hyrax-5.0.2 app/actors/hyrax/actors/lease_actor.rb
hyrax-5.0.1 app/actors/hyrax/actors/lease_actor.rb
hyrax-5.0.0 app/actors/hyrax/actors/lease_actor.rb
hyrax-5.0.0.rc3 app/actors/hyrax/actors/lease_actor.rb