Module: PgSearch::ScopeOptions::WithPgSearchHighlight

Defined in:
lib/pg_search/scope_options.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](tsearch) ⇒ Object



27
28
29
30
31
32
33
# 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

#tsearchObject

Raises:

  • (TypeError)


35
36
37
# File 'lib/pg_search/scope_options.rb', line 35

def tsearch
  raise TypeError, "You need to instantiate this module with []"
end

#with_pg_search_highlightObject



39
40
41
42
43
# File 'lib/pg_search/scope_options.rb', line 39

def with_pg_search_highlight
  scope = self
  scope = scope.select(arel_table[Arel.star]) if scope.select_values.empty?
  scope.select(tsearch.highlight.as("pg_search_highlight"))
end