class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::ProcessRangeQueries

Public Instance Methods

call() click to toggle source
# File lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_range_queries.rb, line 7
  def call
    if range_queries = Celsius::Hash.deep_find_key(source, :range)
      query_terms_node = transformation.inner_search_request.locate("PrimoSearchRequest/QueryTerms").first

      range_queries.each do |range_query|
        lower_bound = Celsius::Hash.smart_fetch(range_query.values.first, :gte)
        upper_bound = Celsius::Hash.smart_fetch(range_query.values.first, :lte)
        index_field = index_field_mapping(range_query.keys.first)

        query_terms_node << Ox.parse(
          <<-xml
            <QueryTerm>
              <IndexField>#{index_field}</IndexField>
              <PrecisionOperator>contains</PrecisionOperator>
              <Value>[#{lower_bound} TO #{upper_bound}]</Value>
            </QueryTerm>
          xml
        )
      end
    end
  end