Module: Hyrax::LeaseHelper

Included in:
HyraxHelperBehavior
Defined in:
app/helpers/hyrax/lease_helper.rb

Instance Method Summary collapse

Instance Method Details

#assets_under_leaseObject


8
9
10
# File 'app/helpers/hyrax/lease_helper.rb', line 8

def assets_under_lease
  @assets_under_lease ||= LeaseService.assets_under_lease
end

#assets_with_deactivated_leasesObject


12
13
14
# File 'app/helpers/hyrax/lease_helper.rb', line 12

def assets_with_deactivated_leases
  @assets_with_deactivated_leases ||= LeaseService.assets_with_deactivated_leases
end

#assets_with_expired_leasesObject


4
5
6
# File 'app/helpers/hyrax/lease_helper.rb', line 4

def assets_with_expired_leases
  @assets_with_expired_leases ||= LeaseService.assets_with_expired_leases
end

#lease_enforced?(resource) ⇒ Boolean

Note:

Hyrax::Forms::Failedsubmissionformwrapper is a place holder until we switch to Valkyrie::ChangeSet instead of Form objects

Returns whether the resource has an lease that is currently enforced (regardless of whether it has expired).

Parameters:

Returns:

  • (Boolean)

    whether the resource has an lease that is currently enforced (regardless of whether it has expired)

Since:

  • 3.0.0


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/hyrax/lease_helper.rb', line 27

def lease_enforced?(resource)
  # This is a guard; from the UI rendering perspective, there's no
  # active lease enforcement until the object is saved.
  return false unless resource.persisted?

  case resource
  when Hydra::AccessControls::Embargoable
    !resource.lease_expiration_date.nil?
  when HydraEditor::Form, Hyrax::Forms::FailedSubmissionFormWrapper
    lease_enforced?(resource.model)
  when Valkyrie::ChangeSet
    Hyrax::LeaseManager.new(resource: resource.model).enforced?
  else
    Hyrax::LeaseManager.new(resource: resource).enforced?
  end
end