module PgSearch
def disable_multisearch
def disable_multisearch Thread.current["PgSearch.enable_multisearch"] = false yield ensure Thread.current["PgSearch.enable_multisearch"] = true end
def method_missing(symbol, *args)
def method_missing(symbol, *args) case symbol when :pg_search_rank raise PgSearchRankNotSelected unless respond_to?(:pg_search_rank) read_attribute(:pg_search_rank).to_f when :pg_search_highlight raise PgSearchHighlightNotSelected unless respond_to?(:pg_search_highlight) read_attribute(:pg_search_highlight) else super end end
def multisearch(*args)
def multisearch(*args) PgSearch::Document.search(*args) end
def multisearch_enabled?
def multisearch_enabled? if Thread.current.key?("PgSearch.enable_multisearch") Thread.current["PgSearch.enable_multisearch"] else true end end
def respond_to_missing?(symbol, *args)
def respond_to_missing?(symbol, *args) case symbol when :pg_search_rank attributes.key?(:pg_search_rank) when :pg_search_highlight attributes.key?(:pg_search_highlight) else super end end