Class: Spotlight::SolrDocumentSidecar

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

Instance Method Summary collapse

Instance Method Details

#default_document_typeObject



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

def default_document_type
  blacklight_config.solr_document_model
end

#documentObject

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



22
23
24
# File 'app/models/spotlight/solr_document_sidecar.rb', line 22

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

#document_typeObject



26
27
28
# File 'app/models/spotlight/solr_document_sidecar.rb', line 26

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

#private!Object



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

def private!
  update public: false
end

#public!Object



17
18
19
# File 'app/models/spotlight/solr_document_sidecar.rb', line 17

def public!
  update public: true
end

#to_solrObject



9
10
11
# File 'app/models/spotlight/solr_document_sidecar.rb', line 9

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