Sha256: 05f67972e11a1820020255fee2033fd8d64dd065f15c879d2e9823f82c0dee79

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

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

    # @param [SolrDocument] solr_document
    # @param [Ability] current_ability
    def initialize(solr_document, current_ability)
      @solr_document = solr_document
      @current_ability = current_ability
    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, :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
      Array.wrap(solr_document['label_tesim']).first
    end

    def link_name
      current_ability.can?(:read, id) ? Array.wrap(solr_document['label_tesim']).first : 'File'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
curation_concerns-1.0.0.beta3 app/presenters/curation_concerns/file_set_presenter.rb
curation_concerns-1.0.0.beta2 app/presenters/curation_concerns/file_set_presenter.rb