Class: Blacklight::Response::ViewTypeComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/blacklight/response/view_type_component.rb

Overview

Render spellcheck results for a search query

Constant Summary

Constants inherited from Component

Component::EXCLUDE_VARIABLES

Instance Method Summary collapse

Methods inherited from Component

compiler, config, #inspect

Constructor Details

#initialize(response:, search_state:, views: {}, selected: nil) ⇒ ViewTypeComponent

Returns a new instance of ViewTypeComponent.

Parameters:



10
11
12
13
14
15
# File 'app/components/blacklight/response/view_type_component.rb', line 10

def initialize(response:, search_state:, views: {}, selected: nil)
  @response = response
  @views = views
  @search_state = search_state
  @selected = selected
end

Instance Method Details

#before_renderObject



17
18
19
20
21
22
23
# File 'app/components/blacklight/response/view_type_component.rb', line 17

def before_render
  return if views.any?

  @views.each do |key, config|
    with_view(key: key, view: config, selected: @selected == key, search_state: @search_state)
  end
end

#render?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/components/blacklight/response/view_type_component.rb', line 25

def render?
  views.many? && !@response.empty?
end