Sha256: e6e4b79a9edf682fdf4a8b73a22e4c6f3741b1f4487117a2632883b6a8bf9082
Contents?: true
Size: 879 Bytes
Versions: 6
Compression:
Stored size: 879 Bytes
Contents
module ThinkingSphinx module ActiveRecord module Scopes def self.included(base) base.class_eval do extend ThinkingSphinx::ActiveRecord::Scopes::ClassMethods end end module ClassMethods def sphinx_scope(method, &block) @sphinx_scopes ||= [] @sphinx_scopes << method metaclass.instance_eval do define_method(method) do |*args| options = block.call(*args) ThinkingSphinx::Search.new(options) end end end def sphinx_scopes @sphinx_scopes || [] end def remove_sphinx_scopes sphinx_scopes.each do |scope| metaclass.send(:undef_method, scope) end sphinx_scopes.clear end end end end end
Version data entries
6 entries across 6 versions & 2 rubygems