Sha256: 1eb43147eeccb82b09ba994eb0bb411a69347643800ba4910146df43ab314742

Contents?: true

Size: 705 Bytes

Versions: 1

Compression:

Stored size: 705 Bytes

Contents

module PgSearch
  module Features
    class Feature
      def initialize(query, options, columns, model, normalizer)
        @query = query
        @options = options || {}
        @columns = columns
        @model = model
        @normalizer = normalizer
      end

      private

      attr_reader :query, :options, :columns, :model, :normalizer

      def document
        if columns.length == 1
          columns.first.to_sql
        else
          expressions = columns.map { |column| column.to_sql }.join(", ")
          "array_to_string(ARRAY[#{expressions}], ' ')"
        end
      end

      def normalize(expression)
        normalizer.add_normalization(expression)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pg_search-0.5.5 lib/pg_search/features/feature.rb