Sha256: 3666a5ad77c5604880844efa899773964b5adb05479bc12d2b5a02f870e05037
Contents?: true
Size: 996 Bytes
Versions: 3
Compression:
Stored size: 996 Bytes
Contents
require 'digest' module PgSearch class Configuration class Column attr_reader :weight, :association def initialize(column_name, weight, model, association = nil) @column_name = column_name.to_s @weight = weight @model = model @association = association end def table foreign? ? @association.table_name : @model.table_name end def full_name "#{@model.connection.quote_table_name(table)}.#{@model.connection.quote_column_name(@column_name)}" end def to_sql name = if foreign? "#{@association.subselect_alias}.#{self.alias}" else full_name end "coalesce(#{name}, '')" end def foreign? @association.present? end def alias name = [association.subselect_alias, @column_name].compact.join('_') "pg_search_#{Digest::SHA2.hexdigest(name)}" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pg_search-0.2.2 | lib/pg_search/configuration/column.rb |
pg_search-0.2.1 | lib/pg_search/configuration/column.rb |
pg_search-0.2 | lib/pg_search/configuration/column.rb |