Module: Europeana::Blacklight::SearchBuilder::OverlayParams

Extended by:
ActiveSupport::Concern
Included in:
Europeana::Blacklight::SearchBuilder
Defined in:
lib/europeana/blacklight/search_builder/overlay_params.rb

Overview

“Overlay” params do not replace others, but are combined with them, into multiple values for those param keys

Instance Method Summary collapse

Instance Method Details

#add_overlay_params_to_api(api_parameters) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/europeana/blacklight/search_builder/overlay_params.rb', line 22

def add_overlay_params_to_api(api_parameters)
  return unless @overlay_params

  @overlay_params.each do |param_set|
    param_set.each_pair do |k, v|
      k = k.to_sym
      api_parameters[k] = if api_parameters.key?(k)
                            [api_parameters[k]].flatten # in case it's not an Array
                          else
                            []
                          end
      api_parameters[k] += [v]
      api_parameters[k] = api_parameters[k].flatten.uniq
    end
  end
end

#with_overlay_params(overlay_params = {}) ⇒ Object



16
17
18
19
20
# File 'lib/europeana/blacklight/search_builder/overlay_params.rb', line 16

def with_overlay_params(overlay_params = {})
  @overlay_params ||= []
  @overlay_params << overlay_params
  self
end