Module: Hyrax::EmbargoHelper

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

Instance Method Summary collapse

Instance Method Details

#assets_under_embargoObject



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

def assets_under_embargo
  @assets_under_embargo ||= EmbargoService.assets_under_embargo
end

#assets_with_deactivated_embargoesObject



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

def assets_with_deactivated_embargoes
  @assets_with_deactivated_embargoes ||= EmbargoService.assets_with_deactivated_embargoes
end

#assets_with_expired_embargoesObject



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

def assets_with_expired_embargoes
  @assets_with_expired_embargoes ||= EmbargoService.assets_with_expired_embargoes
end

#embargo_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 embargo that is currently enforced (regardless of whether it has expired).

Parameters:

Returns:

  • (Boolean)

    whether the resource has an embargo 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/embargo_helper.rb', line 27

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

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

#embargo_history(resource) ⇒ Array

Parameters:

Returns:

  • (Array)

Since:

  • 3.5.0



50
51
52
53
# File 'app/helpers/hyrax/embargo_helper.rb', line 50

def embargo_history(resource)
  resource.try(:embargo_history) ||
    Array(resource.embargo&.embargo_history)
end