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: [], show: false, view_type: nil) ⇒ DocumentMetadataComponent

Returns a new instance of DocumentMetadataComponent.

Parameters:



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

def initialize(fields: [], show: false, view_type: nil)
  @fields = fields
  @show = show
  @view_type = view_type
end

Instance Attribute Details

#view_typeObject (readonly)

Returns the value of attribute view_type.



29
30
31
# File 'app/components/blacklight/document_metadata_component.rb', line 29

def view_type
  @view_type
end

Instance Method Details

#before_renderObject



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

def before_render
  return unless fields

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

#render?Boolean

Returns:

  • (Boolean)


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

def render?
  fields.present?
end