Sha256: e5f80b7c9905327e9d20d172d0b6088c2246cbf81e17af5e3c431005bd82cf01

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

module CurationConcerns
  class CollectionPresenter
    include ModelProxy
    include PresentsAttributes
    include ActionView::Helpers::NumberHelper
    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?, :representative_id,
             :to_s, to: :solr_document

    # Metadata Methods
    delegate :title, :description, :creator, :contributor, :subject, :publisher, :keyword, :language,
             :embargo_release_date, :lease_expiration_date, :rights, :date_created, to: :solr_document

    def size
      number_to_human_size(@solr_document['bytes_lts'])
    end

    def total_items
      @solr_document.fetch('member_ids_ssim', []).length
    end

    def to_s
      title.first
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
curation_concerns-2.0.0 app/presenters/curation_concerns/collection_presenter.rb
curation_concerns-2.0.0.rc2 app/presenters/curation_concerns/collection_presenter.rb
curation_concerns-2.0.0.rc1 app/presenters/curation_concerns/collection_presenter.rb