Sha256: d66beeeb242c3dd30e180d91df68bcb171b2807f2512ad41e406f3195b7352a2

Contents?: true

Size: 631 Bytes

Versions: 3

Compression:

Stored size: 631 Bytes

Contents

module PgSearch
  class Normalizer
    def initialize(config)
      @config = config
    end

    def add_normalization(sql_expression)
      if config.ignore.include?(:accents)
        if config.postgresql_version < 90000
          raise PgSearch::NotSupportedForPostgresqlVersion.new(<<-MESSAGE.gsub /^\s*/, '')
            Sorry, {:ignoring => :accents} only works in PostgreSQL 9.0 and above.
            #{config.inspect}
          MESSAGE
        else
          "#{PgSearch.unaccent_function}(#{sql_expression})"
        end
      else
        sql_expression
      end
    end

    private

    attr_reader :config
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pg_search-0.5.7 lib/pg_search/normalizer.rb
pg_search-0.5.6 lib/pg_search/normalizer.rb
pg_search-0.5.5 lib/pg_search/normalizer.rb