Class: Hyrax::Actors::LeaseActor

Inherits:
Object
  • Object
show all
Defined in:
app/actors/hyrax/actors/lease_actor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(work) ⇒ LeaseActor

Returns a new instance of LeaseActor.

Parameters:

  • work (Hydra::Works::Work)


8
9
10
# File 'app/actors/hyrax/actors/lease_actor.rb', line 8

def initialize(work)
  @work = work
end

Instance Attribute Details

#workObject (readonly)

Returns the value of attribute work.



5
6
7
# File 'app/actors/hyrax/actors/lease_actor.rb', line 5

def work
  @work
end

Instance Method Details

#destroyObject

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



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/actors/hyrax/actors/lease_actor.rb', line 14

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