Sha256: ea8a2019a6c1f057b52772cadea1982565e6d50af23b29432af8c04da9a79105

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

require "active_record"
require "active_support/concern"
require "active_support/core_ext/module/attribute_accessors"

module PgSearch
  extend ActiveSupport::Concern

  mattr_accessor :multisearch_options
  self.multisearch_options = {}

  module ClassMethods
    def pg_search_scope(name, options)
      self.scope(
        name,
        PgSearch::Scope.new(name, self, options).to_proc
      )
    end

    def multisearchable(options = {})
      include PgSearch::Multisearchable
      class_attribute :pg_search_multisearchable_options
      self.pg_search_multisearchable_options = options
    end
  end

  def pg_search_rank
    read_attribute(:pg_search_rank).to_f
  end

  class << self
    def multisearch(*args)
      PgSearch::Document.search(*args)
    end

    def disable_multisearch
      Thread.current["PgSearch.enable_multisearch"] = false
      yield
    ensure
      Thread.current["PgSearch.enable_multisearch"] = true
    end

    def multisearch_enabled?
      Thread.current.key?("PgSearch.enable_multisearch") ? Thread.current["PgSearch.enable_multisearch"] : true
    end
  end

  class NotSupportedForPostgresqlVersion < StandardError; end
end

require "pg_search/configuration"
require "pg_search/document"
require "pg_search/features"
require "pg_search/multisearch"
require "pg_search/multisearchable"
require "pg_search/normalizer"
require "pg_search/scope"
require "pg_search/scope_options"
require "pg_search/version"

require "pg_search/railtie" if defined?(Rails)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pg_search-0.5.1 lib/pg_search.rb
pg_search-0.5 lib/pg_search.rb
pg_search-0.4.2 lib/pg_search.rb