Sha256: ce8384f8e29ba3b2ab6ac838bb6e12182a14346ed2f9014526c3b0adf4345baf

Contents?: true

Size: 821 Bytes

Versions: 11

Compression:

Stored size: 821 Bytes

Contents

module Europeana
  module Blacklight
    class SearchBuilder
      ##
      # Search builder methods for ranges
      module Ranges
        extend ActiveSupport::Concern

        included do
          default_processor_chain << :add_range_qf_to_api
        end

        def add_range_qf_to_api(api_parameters)
          return unless blacklight_params.key?(:range) && blacklight_params[:range].is_a?(Hash)
          blacklight_params[:range].each_pair do |range_field, range_values|
            range_begin = range_values[:begin].blank? ? '*' : range_values[:begin]
            range_end = range_values[:end].blank? ? '*' : range_values[:end]
            api_parameters[:qf] ||= []
            api_parameters[:qf] << "#{range_field}:[#{range_begin} TO #{range_end}]"
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
europeana-blacklight-1.2.2 lib/europeana/blacklight/search_builder/ranges.rb
europeana-blacklight-1.2.1 lib/europeana/blacklight/search_builder/ranges.rb
europeana-blacklight-1.2.0 lib/europeana/blacklight/search_builder/ranges.rb
europeana-blacklight-1.1.0 lib/europeana/blacklight/search_builder/ranges.rb
europeana-blacklight-1.0.0 lib/europeana/blacklight/search_builder/ranges.rb
europeana-blacklight-0.5.2 lib/europeana/blacklight/search_builder/ranges.rb
europeana-blacklight-0.5.1 lib/europeana/blacklight/search_builder/ranges.rb
europeana-blacklight-0.5.0 lib/europeana/blacklight/search_builder/ranges.rb
europeana-blacklight-0.4.9 lib/europeana/blacklight/search_builder/ranges.rb
europeana-blacklight-0.4.8 lib/europeana/blacklight/search_builder/ranges.rb
europeana-blacklight-0.4.7 lib/europeana/blacklight/search_builder/ranges.rb