Module: PgSearch::ScopeOptions::WithPgSearchMultipleHighlight
- Defined in:
- lib/pg_search_multiple_highlight/scope_options.rb
Overview
This a workaround github.com/Casecommons/pg_search/issues/336 issue of the pg_search gem that does not support highlighting results when a tsearch is performed against more than one column
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.[](tsearch) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/pg_search_multiple_highlight/scope_options.rb', line 22 def self.[](tsearch) Module.new do include WithPgSearchMultipleHighlight define_method(:tsearch) { tsearch } end end |
Instance Method Details
#tsearch ⇒ Object
29 30 31 |
# File 'lib/pg_search_multiple_highlight/scope_options.rb', line 29 def tsearch raise TypeError, "You need to instantiate this module with []" end |
#with_pg_search_multiple_highlight ⇒ Object
33 34 35 36 37 38 |
# File 'lib/pg_search_multiple_highlight/scope_options.rb', line 33 def with_pg_search_multiple_highlight scope = self scope.select("#{table_name}.*") unless scope.select_values.any? tsearch.multiple_highlight end |