Class: PgSearch::Configuration::Column
- Inherits:
-
Object
- Object
- PgSearch::Configuration::Column
- Defined in:
- lib/pg_search/configuration/column.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(column_name, weight, model) ⇒ Column
constructor
A new instance of Column.
-
#source_attribute ⇒ Object
Physical source-column attribute, or the supplied trusted SQL literal.
-
#to_arel ⇒ Object
Composable search expression cast to text, with NULL mapped to "".
Constructor Details
#initialize(column_name, weight, model) ⇒ Column
Returns a new instance of Column.
10 11 12 13 14 15 |
# File 'lib/pg_search/configuration/column.rb', line 10 def initialize(column_name, weight, model) @name = column_name.to_s @column_name = column_name @weight = weight @model = model end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/pg_search/configuration/column.rb', line 8 def name @name end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
8 9 10 |
# File 'lib/pg_search/configuration/column.rb', line 8 def weight @weight end |
Instance Method Details
#source_attribute ⇒ Object
Physical source-column attribute, or the supplied trusted SQL literal. Foreign columns refer to the association table, not the search alias.
19 20 21 22 23 |
# File 'lib/pg_search/configuration/column.rb', line 19 def source_attribute return @column_name if @column_name.is_a?(Arel::Nodes::SqlLiteral) Arel::Attributes::Attribute.new(source_table, @name) end |
#to_arel ⇒ Object
Composable search expression cast to text, with NULL mapped to "". Foreign columns use their derived search alias rather than the source.
27 |
# File 'lib/pg_search/configuration/column.rb', line 27 def to_arel = coalesce_to_blank_string(cast_to_text(attribute)) |