Sha256: acaa60793525ba609967f74b1e0c258a71622b5f30e4e7587ee6642bb88cd847

Contents?: true

Size: 661 Bytes

Versions: 10

Compression:

Stored size: 661 Bytes

Contents

require 'digest'

module PgSearch
  class Configuration
    class Column
      attr_reader :weight

      def initialize(column_name, weight, model)
        @column_name = column_name.to_s
        @weight = weight
        @model = model
        @connection = model.connection
      end

      def full_name
        "#{table_name}.#{column_name}"
      end

      def to_sql
        "coalesce(#{expression}::text, '')"
      end

      private

      def table_name
        @model.quoted_table_name
      end

      def column_name
        @connection.quote_column_name(@column_name)
      end

      def expression
        full_name
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pg_search-0.7.5 lib/pg_search/configuration/column.rb
pg_search-0.7.4 lib/pg_search/configuration/column.rb
pg_search-0.7.3 lib/pg_search/configuration/column.rb
pg_search-0.7.2 lib/pg_search/configuration/column.rb
pg_search-0.7.1 lib/pg_search/configuration/column.rb
pg_search-0.7.0 lib/pg_search/configuration/column.rb
pg_search-0.6.4 lib/pg_search/configuration/column.rb
pg_search-0.6.3 lib/pg_search/configuration/column.rb
pg_search-0.6.2 lib/pg_search/configuration/column.rb
pg_search-0.6.1 lib/pg_search/configuration/column.rb