Sha256: d0f1ad2b6acc2458bd751b4a2de9871f1c02bf1bd0637d47584b88b54af16339

Contents?: true

Size: 1.08 KB

Versions: 22

Compression:

Stored size: 1.08 KB

Contents

module Europeana
  module Blacklight
    class SearchBuilder
      ##
      # "Overlay" params do not replace others, but are combined with them, into
      # multiple values for those param keys
      module OverlayParams
        extend ActiveSupport::Concern

        included do
          default_processor_chain << :add_overlay_params_to_api
        end

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

        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
              if api_parameters.key?(k)
                api_parameters[k] = [api_parameters[k]].flatten # in case it's not an Array
              else
                api_parameters[k] = []
              end
              api_parameters[k] += [v]
              api_parameters[k] = api_parameters[k].flatten.uniq
            end
          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
europeana-blacklight-1.2.2 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-1.2.1 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-1.2.0 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-1.1.0 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-1.0.0 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.5.2 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.5.1 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.5.0 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.4.9 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.4.8 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.4.7 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.4.6 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.4.5 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.4.4 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.4.3 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.4.2 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.4.1 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.4.0 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.3.3 lib/europeana/blacklight/search_builder/overlay_params.rb
europeana-blacklight-0.3.2 lib/europeana/blacklight/search_builder/overlay_params.rb