Class: Blacklight::DocumentMetadataComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Blacklight::DocumentMetadataComponent
show all
- Defined in:
- app/components/blacklight/document_metadata_component.rb
Constant Summary
Constants inherited
from Component
Component::EXCLUDE_VARIABLES
Instance Method Summary
collapse
Methods inherited from Component
compiler, config, #inspect
Constructor Details
Returns a new instance of DocumentMetadataComponent.
11
12
13
14
|
# File 'app/components/blacklight/document_metadata_component.rb', line 11
def initialize(fields: [], show: false)
@fields = fields
@show = show
end
|
Instance Method Details
#before_render ⇒ Object
16
17
18
19
20
21
22
|
# File 'app/components/blacklight/document_metadata_component.rb', line 16
def before_render
return unless fields
@fields.each do |field|
field(component: field_component(field), field: field, show: @show)
end
end
|
#field_component(field) ⇒ Object
28
29
30
|
# File 'app/components/blacklight/document_metadata_component.rb', line 28
def field_component(field)
field&.component || Blacklight::MetadataFieldComponent
end
|
#render? ⇒ Boolean
24
25
26
|
# File 'app/components/blacklight/document_metadata_component.rb', line 24
def render?
fields.present?
end
|