Module: ThinkingSphinx::ActiveRecord::Scopes::ClassMethods

Defined in:
lib/thinking_sphinx/active_record/scopes.rb

Instance Method Summary collapse

Instance Method Details

#remove_sphinx_scopesObject



29
30
31
32
33
34
35
# File 'lib/thinking_sphinx/active_record/scopes.rb', line 29

def remove_sphinx_scopes
  sphinx_scopes.each do |scope|
    metaclass.send(:undef_method, scope)
  end
  
  sphinx_scopes.clear
end

#sphinx_scope(method, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/thinking_sphinx/active_record/scopes.rb', line 11

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

#sphinx_scopesObject



25
26
27
# File 'lib/thinking_sphinx/active_record/scopes.rb', line 25

def sphinx_scopes
  @sphinx_scopes || []
end