Class: Blacklight::DocumentMetadataComponent

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

Constant Summary

Constants inherited from Component

Component::EXCLUDE_VARIABLES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Component

compiler, config, #inspect

Constructor Details

#initialize(fields: [], tag: 'dl', classes: %w[document-metadata dl-invert row],, show: false, view_type: nil, field_layout: nil, **component_args) ⇒ DocumentMetadataComponent

rubocop:disable Metrics/ParameterLists

Parameters:



12
13
14
15
16
17
18
19
20
# File 'app/components/blacklight/document_metadata_component.rb', line 12

def initialize(fields: [], tag: 'dl', classes: %w[document-metadata dl-invert row], show: false, view_type: nil, field_layout: nil, **component_args)
  @fields = fields
  @tag = tag
  @classes = classes
  @show = show
  @view_type = view_type
  @field_layout = field_layout
  @component_args = component_args
end

Instance Attribute Details

#view_typeObject (readonly)

Returns the value of attribute view_type.



35
36
37
# File 'app/components/blacklight/document_metadata_component.rb', line 35

def view_type
  @view_type
end

Instance Method Details

#before_renderObject

rubocop:enable Metrics/ParameterLists



23
24
25
26
27
28
29
# File 'app/components/blacklight/document_metadata_component.rb', line 23

def before_render
  return unless fields

  @fields.each do |field|
    with_field(component: field.component, field: field, show: @show, view_type: @view_type, layout: @field_layout)
  end
end

#render?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/components/blacklight/document_metadata_component.rb', line 31

def render?
  fields.present?
end