Class: Spotlight::SolrDocumentSidecar

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spotlight/solr_document_sidecar.rb

Overview

Exhibit-specific metadata for indexed documents

Instance Method Summary collapse

Instance Method Details

#default_document_typeObject



37
38
39
# File 'app/models/spotlight/solr_document_sidecar.rb', line 37

def default_document_type
  blacklight_config.document_model
end

#documentObject

Roll our own polymorphism because our documents are not AREL-able



29
30
31
# File 'app/models/spotlight/solr_document_sidecar.rb', line 29

def document
  document_type.new document_type.unique_key => document_id
end

#document_typeObject



33
34
35
# File 'app/models/spotlight/solr_document_sidecar.rb', line 33

def document_type
  (super.constantize if defined?(super)) || default_document_type
end

#private!Object



20
21
22
# File 'app/models/spotlight/solr_document_sidecar.rb', line 20

def private!
  update public: false
end

#public!Object



24
25
26
# File 'app/models/spotlight/solr_document_sidecar.rb', line 24

def public!
  update public: true
end

#to_solrObject



13
14
15
16
17
18
# File 'app/models/spotlight/solr_document_sidecar.rb', line 13

def to_solr
  { document.class.unique_key.to_sym => document.id,
    visibility_field => public? }
    .merge(data_to_solr)
    .merge(exhibit.solr_data)
end