Module: ThinkingSphinx::ActiveRecord::CollectionProxyWithScopes
- Defined in:
- lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
Class Method Summary collapse
Instance Method Summary collapse
- #method_missing_with_sphinx_scopes(method, *args, &block) ⇒ Object
- #respond_to_with_sphinx_scopes?(method) ⇒ Boolean
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb', line 4 def self.included(base) base.class_eval do alias_method_chain :method_missing, :sphinx_scopes alias_method_chain :respond_to?, :sphinx_scopes end end |
Instance Method Details
#method_missing_with_sphinx_scopes(method, *args, &block) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb', line 11 def method_missing_with_sphinx_scopes(method, *args, &block) klass = proxy_association.klass if klass.respond_to?(:sphinx_scopes) && klass.sphinx_scopes.include?(method) klass.search(:with => default_filter).send(method, *args, &block) else method_missing_without_sphinx_scopes(method, *args, &block) end end |
#respond_to_with_sphinx_scopes?(method) ⇒ Boolean
20 21 22 23 24 |
# File 'lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb', line 20 def respond_to_with_sphinx_scopes?(method) proxy_association.klass.respond_to?(:sphinx_scopes) && proxy_association.klass.sphinx_scopes.include?(method) || respond_to_without_sphinx_scopes?(method) end |