Sha256: 90438b07f016a9fc9ec915b893758a0d563232a4842d24ce6655d4755bc66dd6

Contents?: true

Size: 952 Bytes

Versions: 32

Compression:

Stored size: 952 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 = {:classes => classes_option}
              options.merge! 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

32 entries across 32 versions & 10 rubygems

Version Path
DrMark-thinking-sphinx-1.2.5 lib/thinking_sphinx/active_record/scopes.rb
DrMark-thinking-sphinx-1.2.6 lib/thinking_sphinx/active_record/scopes.rb
bterlson-thinking-sphinx-1.2.8 lib/thinking_sphinx/active_record/scopes.rb
ebeigarts-thinking-sphinx-1.2.10 lib/thinking_sphinx/active_record/scopes.rb
factorylabs-thinking-sphinx-1.2.7 lib/thinking_sphinx/active_record/scopes.rb
freelancing-god-thinking-sphinx-1.2.10 lib/thinking_sphinx/active_record/scopes.rb
freelancing-god-thinking-sphinx-1.2.11 lib/thinking_sphinx/active_record/scopes.rb
freelancing-god-thinking-sphinx-1.2.5 lib/thinking_sphinx/active_record/scopes.rb
freelancing-god-thinking-sphinx-1.2.6 lib/thinking_sphinx/active_record/scopes.rb
freelancing-god-thinking-sphinx-1.2.7 lib/thinking_sphinx/active_record/scopes.rb
freelancing-god-thinking-sphinx-1.2.8 lib/thinking_sphinx/active_record/scopes.rb
freelancing-god-thinking-sphinx-1.2.9 lib/thinking_sphinx/active_record/scopes.rb
hariton-thinking-sphinx-1.2.11.2 lib/thinking_sphinx/active_record/scopes.rb
hariton-thinking-sphinx-1.2.11 lib/thinking_sphinx/active_record/scopes.rb
hariton-thinking-sphinx-1.2.7.0 lib/thinking_sphinx/active_record/scopes.rb
hariton-thinking-sphinx-1.2.7.1 lib/thinking_sphinx/active_record/scopes.rb
thinking-sphinx-1.3.3 lib/thinking_sphinx/active_record/scopes.rb
thinking-sphinx-099-1.3.2 lib/thinking_sphinx/active_record/scopes.rb
thinking-sphinx-1.3.2 lib/thinking_sphinx/active_record/scopes.rb
moneypools-thinking-sphinx-1.3.1 lib/thinking_sphinx/active_record/scopes.rb