Sha256: 0bc1d1a1f12971e0fb1083dc9f1ca92ac7d51dd9e892fcaf9649061e4e2b35c0

Contents?: true

Size: 751 Bytes

Versions: 1

Compression:

Stored size: 751 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  class DocumentMetadataComponent < Blacklight::Component
    renders_many :fields, (lambda do |component: nil, **kwargs|
      component.new(**kwargs)
    end)
    with_collection_parameter :fields

    # @param fields [Enumerable<Blacklight::FieldPresenter>] Document field presenters
    def initialize(fields: [], show: false, view_type: nil)
      @fields = fields
      @show = show
      @view_type = view_type
    end

    def before_render
      return unless fields

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

    def render?
      fields.present?
    end

    attr_reader :view_type
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-8.0.0.beta1 app/components/blacklight/document_metadata_component.rb