Sha256: 4f72a88c5d2885ebf7c9883273c9eb136f4192eead2d97674ee9b7cb73a52922

Contents?: true

Size: 739 Bytes

Versions: 2

Compression:

Stored size: 739 Bytes

Contents

module Ddr::Index
  class QueryValue

    class << self
      # Returns an escaped query value
      # @param value [String] the unescaped value
      # @return [String] the escaped value
      def build(value)
        RSolr.solr_escape(value)
      end

      # Builds an escaped query value for use in filtering on a field for any value in the list of values
      # @param values [Enumerable<String>]
      # @return [String] query value
      def or_values(values)
        unless values.is_a?(::Enumerable) && values.present?
          raise ArgumentError, "`#{self.name}.or_values` requires a non-empty enumerable of strings."
        end
        "(%s)" % values.map { |value| build(value) }.join(" OR ")
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddr-models-2.4.0.rc4 lib/ddr/index/query_value.rb
ddr-models-2.4.0.rc3 lib/ddr/index/query_value.rb