Sha256: bca54990472a0326c1eb5d00d395eea68b573a24f5e212b953f4711f86caba90

Contents?: true

Size: 998 Bytes

Versions: 3

Compression:

Stored size: 998 Bytes

Contents

# frozen_string_literal: true

require "pg_search/multisearch/rebuilder"

module PgSearch
  module Multisearch
    class << self
      def rebuild(model, deprecated_clean_up = nil, clean_up: true)
        unless deprecated_clean_up.nil?
          ActiveSupport::Deprecation.warn(
            "pg_search 3.0 will no longer accept a boolean second argument to PgSearchMultisearch.rebuild, " \
            "use keyword argument `clean_up:` instead."
          )
          clean_up = deprecated_clean_up
        end

        model.transaction do
          PgSearch::Document.where(searchable_type: model.base_class.name).delete_all if clean_up
          Rebuilder.new(model).rebuild
        end
      end
    end

    class ModelNotMultisearchable < StandardError
      def initialize(model_class)
        super
        @model_class = model_class
      end

      def message
        "#{@model_class.name} is not multisearchable. See PgSearch::ClassMethods#multisearchable"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pg_search-2.3.5 lib/pg_search/multisearch.rb
pg_search-2.3.4 lib/pg_search/multisearch.rb
pg_search-2.3.3 lib/pg_search/multisearch.rb