Class: Hyrax::TrophyPresenter
- Inherits:
-
Object
- Object
- Hyrax::TrophyPresenter
- Includes:
- ModelProxy
- Defined in:
- app/presenters/hyrax/trophy_presenter.rb
Overview
Presents works in context as “trophied” for a given user.
Instance Attribute Summary collapse
- #solr_document ⇒ Object readonly
- #SolrDocument ⇒ ::SolrDocument readonly
Class Method Summary collapse
-
.find_by_user(user) ⇒ Array<TrophyPresenter>
A list of all the trophy presenters for the user.
Instance Method Summary collapse
-
#initialize(solr_document) ⇒ TrophyPresenter
constructor
A new instance of TrophyPresenter.
Methods included from ModelProxy
#persisted?, #to_model, #valid_child_concerns
Constructor Details
#initialize(solr_document) ⇒ TrophyPresenter
Returns a new instance of TrophyPresenter.
22 23 24 |
# File 'app/presenters/hyrax/trophy_presenter.rb', line 22 def initialize(solr_document) @solr_document = solr_document end |
Instance Attribute Details
#solr_document ⇒ Object (readonly)
29 30 31 |
# File 'app/presenters/hyrax/trophy_presenter.rb', line 29 def solr_document @solr_document end |
#SolrDocument ⇒ ::SolrDocument (readonly)
29 |
# File 'app/presenters/hyrax/trophy_presenter.rb', line 29 attr_reader :solr_document |
Class Method Details
.find_by_user(user) ⇒ Array<TrophyPresenter>
Returns a list of all the trophy presenters for the user.
37 38 39 40 41 42 43 44 45 46 |
# File 'app/presenters/hyrax/trophy_presenter.rb', line 37 def self.find_by_user(user) ids = user.trophies.pluck(:work_id) return ids if ids.empty? documents = Hyrax::SolrQueryService.new.with_ids(ids: ids).solr_documents documents.map { |doc| new(doc) } rescue RSolr::Error::ConnectionRefused [] end |