Class: CurationConcerns::CollectionPresenter

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::NumberHelper, ModelProxy, PresentsAttributes
Defined in:
app/presenters/curation_concerns/collection_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PresentsAttributes

#attribute_to_html, #display_microdata?, #microdata_type_to_html, #permission_badge, #permission_badge_class

Methods included from ModelProxy

#persisted?, #to_model, #to_partial_path

Constructor Details

#initialize(solr_document, current_ability, request = nil) ⇒ CollectionPresenter

Returns a new instance of CollectionPresenter.

Parameters:

  • solr_document (SolrDocument)
  • current_ability (Ability)
  • request (ActionDispatch::Request) (defaults to: nil)

    the http request context



11
12
13
14
15
# File 'app/presenters/curation_concerns/collection_presenter.rb', line 11

def initialize(solr_document, current_ability, request = nil)
  @solr_document = solr_document
  @current_ability = current_ability
  @request = request
end

Instance Attribute Details

#current_abilityObject

Returns the value of attribute current_ability.



6
7
8
# File 'app/presenters/curation_concerns/collection_presenter.rb', line 6

def current_ability
  @current_ability
end

#requestObject

Returns the value of attribute request.



6
7
8
# File 'app/presenters/curation_concerns/collection_presenter.rb', line 6

def request
  @request
end

#solr_documentObject

Returns the value of attribute solr_document.



6
7
8
# File 'app/presenters/curation_concerns/collection_presenter.rb', line 6

def solr_document
  @solr_document
end

Instance Method Details

#sizeObject



25
26
27
# File 'app/presenters/curation_concerns/collection_presenter.rb', line 25

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

#to_sObject



33
34
35
# File 'app/presenters/curation_concerns/collection_presenter.rb', line 33

def to_s
  title.first
end

#total_itemsObject



29
30
31
# File 'app/presenters/curation_concerns/collection_presenter.rb', line 29

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