module PgSearch::ScopeOptions::WithPgSearchHighlight

Public Class Methods

[](tsearch) click to toggle source
# File lib/pg_search/scope_options.rb, line 27
def self.[](tsearch)
  Module.new do
    include WithPgSearchHighlight
    define_method(:tsearch) { tsearch }
  end
end

Public Instance Methods

highlight() click to toggle source
# File lib/pg_search/scope_options.rb, line 44
def highlight
  tsearch.highlight.to_sql
end
tsearch() click to toggle source
# 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() click to toggle source
# File lib/pg_search/scope_options.rb, line 38
def with_pg_search_highlight
  scope = self
  scope = scope.select("#{table_name}.*") unless scope.select_values.any?
  scope.select("(#{highlight}) AS pg_search_highlight")
end