Sha256: d0239027350320bae6a7f3b1accc80c1bd7f007409268bade1bd7d56f7fcda63

Contents?: true

Size: 599 Bytes

Versions: 12

Compression:

Stored size: 599 Bytes

Contents

# frozen_string_literal: true

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

12 entries across 12 versions & 1 rubygems

Version Path
pg_search-2.3.6 lib/pg_search/normalizer.rb
pg_search-2.3.5 lib/pg_search/normalizer.rb
pg_search-2.3.4 lib/pg_search/normalizer.rb
pg_search-2.3.3 lib/pg_search/normalizer.rb
pg_search-2.3.2 lib/pg_search/normalizer.rb
pg_search-2.3.1 lib/pg_search/normalizer.rb
pg_search-2.3.0 lib/pg_search/normalizer.rb
pg_search-2.2.0 lib/pg_search/normalizer.rb
pg_search-2.1.7 lib/pg_search/normalizer.rb
pg_search-2.1.6 lib/pg_search/normalizer.rb
pg_search-2.1.5 lib/pg_search/normalizer.rb
pg_search-2.1.4 lib/pg_search/normalizer.rb