Class: Hyrax::TrophyPresenter

Inherits:
Object
  • Object
show all
Includes:
ModelProxy
Defined in:
app/presenters/hyrax/trophy_presenter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_documentObject (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.

Parameters:

  • user (User)

    the user to find the TrophyPresentes for.

Returns:

  • (Array<TrophyPresenter>)

    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