module PgSearch::Model::ClassMethods

Public Instance Methods

multisearchable(options = {}) click to toggle source
# File lib/pg_search/model.rb, line 24
def multisearchable(options = {})
  include PgSearch::Multisearchable
  class_attribute :pg_search_multisearchable_options
  self.pg_search_multisearchable_options = options
end
pg_search_scope(name, options) click to toggle source
# File lib/pg_search/model.rb, line 8
def pg_search_scope(name, options)
  options_proc = if options.respond_to?(:call)
    options
  elsif options.respond_to?(:merge)
    ->(query) { {query: query}.merge(options) }
  else
    raise ArgumentError, "pg_search_scope expects a Hash or Proc"
  end

  define_singleton_method(name) do |*args|
    config = Configuration.new(options_proc.call(*args), self)
    scope_options = ScopeOptions.new(config)
    scope_options.apply(self)
  end
end