Sha256: 85834a16f1b16d139f713721488502e1c667071975acfbdbcf9f6c4f11d1e9b9

Contents?: true

Size: 964 Bytes

Versions: 1

Compression:

Stored size: 964 Bytes

Contents

module CurationConcerns
  module IndexesThumbnails
    extend ActiveSupport::Concern

    included do
      class_attribute :thumbnail_path_service
      self.thumbnail_path_service = ThumbnailPathService
      class_attribute :thumbnail_field
      self.thumbnail_field = 'thumbnail_path_ss'.freeze
    end

    # Adds thumbnail indexing to the solr document
    def generate_solr_document
      super.tap do |solr_doc|
        index_thumbnails(solr_doc)
      end
    end

    # Write the thumbnail paths into the solr_document
    # @params [Hash] solr_document the solr document to add the field to
    def index_thumbnails(solr_document)
      solr_document[thumbnail_field] = thumbnail_path
      solr_document[Solrizer.solr_name('thumbnail_id', :symbol)] = object.thumbnail_id
    end

    # Returns the value for the thumbnail path to put into the solr document
    def thumbnail_path
      self.class.thumbnail_path_service.call(object)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
curation_concerns-1.5.0 app/services/curation_concerns/indexes_thumbnails.rb