Class: Spotlight::Resources::Upload

Inherits:
Spotlight::Resource show all
Includes:
ImageDerivatives
Defined in:
app/models/spotlight/resources/upload.rb

Overview

Exhibit-specific resources, created using uploaded and custom fields

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ImageDerivatives

#apply_spotlight_image_derivative_versions

Methods inherited from Spotlight::Resource

#reindex_later, #save_and_index

Methods included from SolrDocument::AtomicUpdates

#reindex, #write?

Class Method Details

.fields(exhibit) ⇒ Object



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

def self.fields(exhibit)
  @fields ||= {}
  @fields[exhibit] ||= begin
    title_field = Spotlight::Engine.config.upload_title_field || OpenStruct.new(field_name: exhibit.blacklight_config.index.title_field)
    [title_field] + exhibit.uploaded_resource_fields
  end
end

Instance Method Details

#configured_fieldsObject



21
22
23
# File 'app/models/spotlight/resources/upload.rb', line 21

def configured_fields
  self.class.fields(exhibit)
end

#to_solrObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/spotlight/resources/upload.rb', line 25

def to_solr
  store_url! # so that #url doesn't return the tmp directory

  solr_hash = super

  add_default_solr_fields solr_hash

  add_image_dimensions solr_hash

  add_file_versions solr_hash

  add_sidecar_fields solr_hash

  solr_hash
end