Class: Blacklight::FieldPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/blacklight/field_presenter.rb

Overview

Renders a field and handles link_to_search or helper_method if supplied

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, document, field_config, options) ⇒ FieldPresenter

Returns a new instance of FieldPresenter.



4
5
6
7
8
9
# File 'app/presenters/blacklight/field_presenter.rb', line 4

def initialize(controller, document, field_config, options)
  @controller = controller
  @document = document
  @field_config = field_config
  @options = options
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



11
12
13
# File 'app/presenters/blacklight/field_presenter.rb', line 11

def controller
  @controller
end

#documentObject (readonly)

Returns the value of attribute document.



11
12
13
# File 'app/presenters/blacklight/field_presenter.rb', line 11

def document
  @document
end

#field_configObject (readonly)

Returns the value of attribute field_config.



11
12
13
# File 'app/presenters/blacklight/field_presenter.rb', line 11

def field_config
  @field_config
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'app/presenters/blacklight/field_presenter.rb', line 11

def options
  @options
end

Instance Method Details

#renderObject



13
14
15
16
17
18
19
20
21
22
23
# File 'app/presenters/blacklight/field_presenter.rb', line 13

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