Sha256: c4a66e4e70d59b144ee8be822fe88836524f097046cd080dec10e80e47fdc104

Contents?: true

Size: 694 Bytes

Versions: 1

Compression:

Stored size: 694 Bytes

Contents

module Spotlight
  class SolrDocumentSidecar < ActiveRecord::Base
    belongs_to :exhibit
    belongs_to :solr_document
    serialize :data, Hash

    delegate :has_key?, to: :data

    def to_solr
      { blacklight_config.solr_document_model.unique_key.to_sym => solr_document_id, visibility_field => public? }.merge(data_to_solr)
    end

    def private!
      update public: false
    end

    def public!
      update public: true
    end

    protected

    def visibility_field
      Spotlight::SolrDocument.visibility_field(exhibit)
    end

    def blacklight_config
      exhibit.blacklight_config
    end

    def data_to_solr
      Hash[data.map { |k,v| [k,v] }]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-spotlight-0.2.0 app/models/spotlight/solr_document_sidecar.rb