Sha256: 1f44cf01af83ef67286ddeb5dab8c2dd75b553aef124c4041dc7785f7d082b24

Contents?: true

Size: 568 Bytes

Versions: 6

Compression:

Stored size: 568 Bytes

Contents

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

    def add_normalization(sql_expression)
      return sql_expression unless config.ignore.include?(:accents)

      sql_node = case sql_expression
                 when Arel::Nodes::Node
                   sql_expression
                 else
                   Arel.sql(sql_expression)
                 end

      Arel::Nodes::NamedFunction.new(
        PgSearch.unaccent_function,
        [sql_node]
      ).to_sql
    end

    private

    attr_reader :config
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pg_search-2.1.3 lib/pg_search/normalizer.rb
pg_search-2.1.2 lib/pg_search/normalizer.rb
pg_search-2.1.1 lib/pg_search/normalizer.rb
pg_search-2.1.0 lib/pg_search/normalizer.rb
pg_search-2.0.1 lib/pg_search/normalizer.rb
pg_search-2.0.0 lib/pg_search/normalizer.rb