Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Proposed extraction of SolrDocFor
module ActiveFedora
module Plugin
module SolrDocFor
class_attribute :default_solr_document_class
self.default_solr_document_class = ::SolrDocument
# @param [String] id - of the object to cast to the given :solr_document_class
# @param [#new] solr_document_class
# @return Instance of the configured ActiveFedora::Plugin::SolrDocFor.default_solr_document_class
# @see ActiveFedora::Plugin::SolrDocFor.default_solr_document_class
def self.solr_doc_for(id:, solr_document_class: default_solr_document_class)
query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([id])
solr_response = ActiveFedora::SolrService.get(query)
solr_document_class.new(solr_response['response']['docs'].first, solr_response)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.