Sha256: ab0abc057d510ffbe9c1eb64c3d64a44f16695eb60f5d2859915f38fddd32c97

Contents?: true

Size: 1.32 KB

Versions: 39

Compression:

Stored size: 1.32 KB

Contents

module SirTrevorRails
  module Blocks
    ##
    # Multi-up document viewer with text block
    class SolrDocumentsBlock < SirTrevorRails::Block
      include Textable
      attr_reader :solr_helper

      def with_solr_helper(solr_helper)
        @solr_helper = solr_helper
      end

      def each_document
        return to_enum(:each_document) unless block_given?

        items.each do |i|
          document = documents.detect { |doc| doc.id == i[:id] }
          yield i, document if document
        end
      end

      def documents
        @documents ||= begin
          doc_ids = items.map { |v| v[:id] }
          _, documents = solr_helper.fetch(doc_ids)
          documents
        end
      end

      def documents?
        each_document.any?
      end

      def items
        (item || {}).values.select { |x| x[:display] == 'true' }
      end

      def primary_caption?
        primary_caption_field.present? && send(:'show-primary-caption')
      end

      def secondary_caption?
        secondary_caption_field.present? && send(:'show-secondary-caption')
      end

      def primary_caption_field
        val = send(:'primary-caption-field')
        val unless val.blank?
      end

      def secondary_caption_field
        val = send(:'secondary-caption-field')
        val unless val.blank?
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
blacklight-spotlight-0.25.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.24.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.23.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.22.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.21.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.20.3 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.20.2 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.20.1 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.20.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.19.2 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.19.1 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.19.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.18.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.17.1 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.17.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.16.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.15.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.14.2 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.14.1 app/models/sir_trevor_rails/blocks/solr_documents_block.rb
blacklight-spotlight-0.14.0 app/models/sir_trevor_rails/blocks/solr_documents_block.rb