Class: SolrDocumentSidecar

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/solr_document_sidecar.rb

Overview

Metadata for indexed documents

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.image_urlObject



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

def self.image_url
  Rails.application.routes.url_helpers.rails_blob_path(image, only_path: true)
end

.transition_classObject



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

def self.transition_class
  SidecarImageTransition
end

Instance Method Details

#documentObject



15
16
17
# File 'app/models/solr_document_sidecar.rb', line 15

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

#document_typeObject



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

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

#image_stateObject



23
24
25
26
27
28
# File 'app/models/solr_document_sidecar.rb', line 23

def image_state
  @image_state ||= SidecarImageStateMachine.new(
    self,
    transition_class: SidecarImageTransition
  )
end

#reimage!Object



42
43
44
45
# File 'app/models/solr_document_sidecar.rb', line 42

def reimage!
  image.purge if image.attached?
  GeoblacklightSidecarImages::StoreImageJob.perform_later(document.id)
end