Created
March 21, 2017 14:46
-
-
Save jeremyf/cc8f7142d07edd873c989b8903ee5bb1 to your computer and use it in GitHub Desktop.
Proposed extraction of SolrDocFor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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