module PgSearch::ScopeOptions::WithPgSearchHighlight

def self.[](tsearch)

def self.[](tsearch)
  Module.new do
    include WithPgSearchHighlight
    define_method(:tsearch) { tsearch }
  end
end

def highlight

def highlight
  tsearch.highlight.to_sql
end

def tsearch

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

def with_pg_search_highlight

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