Class: Blacklight::Document::ThumbnailComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/blacklight/document/thumbnail_component.rb

Overview

Render the thumbnail for the document

Constant Summary

Constants inherited from Component

Component::EXCLUDE_VARIABLES

Instance Method Summary collapse

Methods inherited from Component

compiler, config, #inspect

Constructor Details

#initialize(counter:, presenter: nil, document: nil, image_options: {}) ⇒ ThumbnailComponent

Returns a new instance of ThumbnailComponent.

Parameters:

  • presenter (Blacklight::DocumentPresenter) (defaults to: nil)
  • counter (Integer)
  • image_options (Hash) (defaults to: {})

    options for the thumbnail presenter’s image tag



12
13
14
15
16
17
# File 'app/components/blacklight/document/thumbnail_component.rb', line 12

def initialize(counter:, presenter: nil, document: nil, image_options: {})
  @presenter = presenter
  @document = presenter&.document || document
  @counter = counter
  @image_options = { alt: '' }.merge(image_options)
end

Instance Method Details

#presenterObject



23
24
25
# File 'app/components/blacklight/document/thumbnail_component.rb', line 23

def presenter
  @presenter ||= helpers.document_presenter(@document)
end

#render?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/components/blacklight/document/thumbnail_component.rb', line 19

def render?
  presenter.thumbnail.exists?
end