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

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

Instance Method Summary collapse

Instance Method Details

#remove_sphinx_scopesObject



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

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
# 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 = block.call(*args)
      ThinkingSphinx::Search.new(options)
    end
  end
end

#sphinx_scopesObject



23
24
25
# File 'lib/thinking_sphinx/active_record/scopes.rb', line 23

def sphinx_scopes
  @sphinx_scopes || []
end