Sha256: e5eef45337c176a2d9290a99fe80c65d06e4bbfb394ad10f8a685fffe98646d2

Contents?: true

Size: 801 Bytes

Versions: 5

Compression:

Stored size: 801 Bytes

Contents

require "active_record"
require "pg_search/configuration"
require "pg_search/features"
require "pg_search/normalizer"
require "pg_search/scope"
require "pg_search/scope_options"
require "pg_search/version"
#require "pg_search/railtie" if defined?(Rails) && defined?(Rails::Railtie)

module PgSearch
  def self.included(base)
    base.send(:extend, ClassMethods)
  end

  module ClassMethods
    def pg_search_scope(name, options)
      scope = PgSearch::Scope.new(name, self, options)
      scope_method =
        if respond_to?(:scope) && !protected_methods.include?('scope')
          :scope # ActiveRecord 3.x
        else
          :named_scope # ActiveRecord 2.x
        end

      send(scope_method, name, scope.to_proc)
    end
  end

  def rank
    attributes['pg_search_rank'].to_f
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pg_search-0.2.1 lib/pg_search.rb
pg_search-0.2 lib/pg_search.rb
pg_search-0.1.1 lib/pg_search.rb
pg_search-0.1 lib/pg_search.rb
pg_search-0.0.2 lib/pg_search.rb