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 pg_search_highlight_field

def pg_search_highlight_field
  "(#{highlight}) AS pg_search_highlight, #{table_name}.*"
end

def tsearch

def tsearch
  raise TypeError.new("You need to instantiate this module with []")
end

def with_pg_search_highlight

def with_pg_search_highlight
  scope = self
  scope.select(pg_search_highlight_field)
end