Sha256: 370eb97930d2a35c8187800304e9c5a1e94b1da1e45f4b84bf889de578a2e79f

Contents?: true

Size: 892 Bytes

Versions: 38

Compression:

Stored size: 892 Bytes

Contents

module Blacklight
  # Renders a field and handles link_to_search or helper_method if supplied
  class FieldPresenter
    def initialize(controller, document, field_config, options)
      @controller = controller
      @document = document
      @field_config = field_config
      @options = options
    end

    attr_reader :controller, :document, :field_config, :options
    
    def render
      if options[:value]
        # This prevents helper methods from drawing.
        config = Configuration::NullField.new(field_config.to_h.except(:helper_method))
        values = Array.wrap(options[:value])
      else
        config = field_config
        values = retrieve_values
      end
      Rendering::Pipeline.render(values, config, document, controller, options)
    end

    private

      def retrieve_values
        FieldRetriever.new(document, field_config).fetch
      end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
blacklight-6.25.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.24.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.23.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.22.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.21.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.20.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.19.2 app/presenters/blacklight/field_presenter.rb
blacklight-6.19.1 app/presenters/blacklight/field_presenter.rb
blacklight-6.19.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.18.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.17.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.16.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.15.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.14.1 app/presenters/blacklight/field_presenter.rb
blacklight-6.14.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.13.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.12.0 app/presenters/blacklight/field_presenter.rb
blacklight-6.11.2 app/presenters/blacklight/field_presenter.rb
blacklight-6.11.1 app/presenters/blacklight/field_presenter.rb
blacklight-6.11.0 app/presenters/blacklight/field_presenter.rb