Class: Spotlight::SolrDocumentBuilder
- Inherits:
-
Object
- Object
- Spotlight::SolrDocumentBuilder
- Defined in:
- app/services/spotlight/solr_document_builder.rb
Overview
Creates solr documents for the documents in a resource
Direct Known Subclasses
Defined Under Namespace
Modules: NilSolrDocument
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
-
#documents_to_index ⇒ Object
An enumerator of all the indexable documents for this resource.
-
#initialize(resource) ⇒ SolrDocumentBuilder
constructor
A new instance of SolrDocumentBuilder.
Constructor Details
#initialize(resource) ⇒ SolrDocumentBuilder
Returns a new instance of SolrDocumentBuilder.
4 5 6 |
# File 'app/services/spotlight/solr_document_builder.rb', line 4 def initialize(resource) @resource = resource end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
8 9 10 |
# File 'app/services/spotlight/solr_document_builder.rb', line 8 def resource @resource end |
Instance Method Details
#documents_to_index ⇒ Object
Returns an enumerator of all the indexable documents for this resource.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/spotlight/solr_document_builder.rb', line 13 def documents_to_index data = to_solr return [] if data.blank? data &&= [data] if data.is_a? Hash return to_enum(:documents_to_index) { data.size } unless block_given? data.lazy.reject(&:blank?).each do |doc| yield doc.reverse_merge(exhibit_solr_doc(doc[unique_key]).to_solr) end end |