Sha256: 9958867deb6e4eb4b149d41e183da72a78b681b15cb12aa6fb56ec8ac944f682

Contents?: true

Size: 1.49 KB

Versions: 18

Compression:

Stored size: 1.49 KB

Contents

module CurationConcerns
  class FileSetPresenter
    include ModelProxy
    include PresentsAttributes
    include CurationConcerns::CharacterizationBehavior
    attr_accessor :solr_document, :current_ability, :request

    # @param [SolrDocument] solr_document
    # @param [Ability] current_ability
    # @param [ActionDispatch::Request] request the http request context
    def initialize(solr_document, current_ability, request = nil)
      @solr_document = solr_document
      @current_ability = current_ability
      @request = request
    end

    # CurationConcern methods
    delegate :stringify_keys, :human_readable_type, :collection?, :image?, :video?,
             :audio?, :pdf?, :office_document?, :representative_id, :to_s, to: :solr_document

    # Methods used by blacklight helpers
    delegate :has?, :first, :fetch, to: :solr_document

    # Metadata Methods
    delegate :title, :label, :description, :creator, :contributor, :subject,
             :publisher, :language, :date_uploaded, :rights,
             :embargo_release_date, :lease_expiration_date,
             :depositor, :keyword, :title_or_label, to: :solr_document

    def page_title
      label
    end

    def link_name
      current_ability.can?(:read, id) ? label : 'File'
    end

    def single_use_links
      @single_use_links ||= SingleUseLink.where(itemId: id).map { |link| link_presenter_class.new(link) }
    end

    private

      def link_presenter_class
        CurationConcerns::SingleUseLinkPresenter
      end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.7.7 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-2.0.0 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-2.0.0.rc2 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.7.6 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.7.5 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.7.4 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.7.3 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.7.2 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-2.0.0.rc1 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.7.1 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.7.0 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.7.0.beta1 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.6.3 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.6.2 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.6.1 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.6.0 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.5.0 app/presenters/curation_concerns/file_set_presenter.rb