Module: PgSearch::ScopeOptions::WithPgSearchHighlight
- Defined in:
- lib/pg_search/scope_options.rb
Class Method Summary collapse
Instance Method Summary collapse
- #highlight ⇒ Object
- #pg_search_highlight_field ⇒ Object
- #tsearch ⇒ Object
- #with_pg_search_highlight ⇒ Object
Class Method Details
.[](tsearch) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/pg_search/scope_options.rb', line 27 def self.[](tsearch) Module.new do include WithPgSearchHighlight define_method(:tsearch) { tsearch } end end |
Instance Method Details
#highlight ⇒ Object
47 48 49 |
# File 'lib/pg_search/scope_options.rb', line 47 def highlight tsearch.highlight.to_sql end |
#pg_search_highlight_field ⇒ Object
43 44 45 |
# File 'lib/pg_search/scope_options.rb', line 43 def pg_search_highlight_field "(#{highlight}) AS pg_search_highlight, #{table_name}.*" end |
#tsearch ⇒ Object
34 35 36 |
# File 'lib/pg_search/scope_options.rb', line 34 def tsearch raise TypeError, "You need to instantiate this module with []" end |
#with_pg_search_highlight ⇒ Object
38 39 40 41 |
# File 'lib/pg_search/scope_options.rb', line 38 def with_pg_search_highlight scope = self scope.select(pg_search_highlight_field) end |