Sha256: 625c6dfb377a678502abb92aac933904d3553169265584e6377addd22fd295c7

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true
module Hyrax
  module EmbargoHelper
    def assets_with_expired_embargoes
      @assets_with_expired_embargoes ||= EmbargoService.assets_with_expired_embargoes
    end

    def assets_under_embargo
      @assets_under_embargo ||= EmbargoService.assets_under_embargo
    end

    def assets_with_deactivated_embargoes
      @assets_with_deactivated_embargoes ||= EmbargoService.assets_with_deactivated_embargoes
    end

    ##
    # @since 3.0.0
    #
    # @param [Valkyrie::Resource, ActiveFedora::Base] resource
    #
    # @return [Boolean] whether the resource has an embargo that is currently
    #   enforced (regardless of whether it has expired)
    #
    # @note Hyrax::Forms::Failedsubmissionformwrapper is a place
    #   holder until we switch to Valkyrie::ChangeSet instead of Form
    #   objects
    def embargo_enforced?(resource)
      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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hyrax-3.0.1 app/helpers/hyrax/embargo_helper.rb
hyrax-3.0.0 app/helpers/hyrax/embargo_helper.rb
hyrax-3.0.0.pre.rc4 app/helpers/hyrax/embargo_helper.rb
hyrax-3.0.0.pre.rc3 app/helpers/hyrax/embargo_helper.rb