Class: SolrDocumentSidecar
- Inherits:
-
GeoblacklightSidecarImages::ApplicationRecord
- Object
- ActiveRecord::Base
- GeoblacklightSidecarImages::ApplicationRecord
- SolrDocumentSidecar
- Defined in:
- app/models/solr_document_sidecar.rb
Overview
ActiveRecord sidecar for a Solr document, with an attached thumbnail image.
Class Method Summary collapse
Instance Method Summary collapse
-
#document ⇒ Object
SolrDocument is not an ActiveRecord model.
- #document_type ⇒ Object
- #image_state ⇒ Object
- #image_url ⇒ Object
- #reimage! ⇒ Object
Class Method Details
.transition_class ⇒ Object
33 34 35 |
# File 'app/models/solr_document_sidecar.rb', line 33 def self.transition_class SidecarImageTransition end |
Instance Method Details
#document ⇒ Object
SolrDocument is not an ActiveRecord model. Reconstruct from the stored id.
18 19 20 |
# File 'app/models/solr_document_sidecar.rb', line 18 def document document_type.new document_type.unique_key => document_id end |
#document_type ⇒ Object
22 23 24 |
# File 'app/models/solr_document_sidecar.rb', line 22 def document_type (super.constantize if defined?(super)) || default_document_type end |
#image_state ⇒ Object
26 27 28 29 30 31 |
# File 'app/models/solr_document_sidecar.rb', line 26 def image_state @image_state ||= SidecarImageStateMachine.new( self, transition_class: SidecarImageTransition ) end |
#image_url ⇒ Object
41 42 43 44 45 |
# File 'app/models/solr_document_sidecar.rb', line 41 def image_url return unless image.attached? Rails.application.routes.url_helpers.rails_blob_path(image, only_path: true) end |
#reimage! ⇒ Object
47 48 49 50 |
# File 'app/models/solr_document_sidecar.rb', line 47 def reimage! image.purge if image.attached? GeoblacklightSidecarImages::StoreImageJob.perform_later(document.id) end |