Class: Hyrax::TrophyPresenter
- Inherits:
-
Object
- Object
- Hyrax::TrophyPresenter
- Includes:
- ModelProxy
- Defined in:
- app/presenters/hyrax/trophy_presenter.rb
Instance Attribute Summary collapse
-
#solr_document ⇒ Object
readonly
Returns the value of attribute solr_document.
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, #to_partial_path
Constructor Details
#initialize(solr_document) ⇒ TrophyPresenter
Returns a new instance of TrophyPresenter.
4 5 6 |
# File 'app/presenters/hyrax/trophy_presenter.rb', line 4 def initialize(solr_document) @solr_document = solr_document end |
Instance Attribute Details
#solr_document ⇒ Object (readonly)
Returns the value of attribute solr_document.
8 9 10 |
# File 'app/presenters/hyrax/trophy_presenter.rb', line 8 def solr_document @solr_document end |
Class Method Details
.find_by_user(user) ⇒ Array<TrophyPresenter>
Returns a list of all the trophy presenters for the user.
14 15 16 17 18 19 20 21 |
# File 'app/presenters/hyrax/trophy_presenter.rb', line 14 def self.find_by_user(user) work_ids = user.trophies.pluck(:work_id) query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids(work_ids) results = Hyrax::WorkRelation.new.search_with_conditions(query) results.map { |result| TrophyPresenter.new(document_model.new(result)) } rescue RSolr::Error::ConnectionRefused [] end |