Sha256: bb7fbc4ef94b1d979a848e7c47d83d7861d8b81590103ce5b6e9383e47cf85b6

Contents?: true

Size: 910 Bytes

Versions: 16

Compression:

Stored size: 910 Bytes

Contents

module ThinkingSphinx
  module ActiveRecord
    module CollectionProxyWithScopes
      def self.included(base)
        base.class_eval do
          alias_method_chain :method_missing, :sphinx_scopes
          alias_method_chain :respond_to?, :sphinx_scopes
        end
      end

      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

      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
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
friendlyfashion-thinking-sphinx-2.0.14.4 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
friendlyfashion-thinking-sphinx-2.0.14.3 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
thinking-sphinx-2.1.0 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
friendlyfashion-thinking-sphinx-2.0.14.2 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
friendlyfashion-thinking-sphinx-2.0.14.1 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
thinking-sphinx-2.0.14 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
friendlyfashion-thinking-sphinx-2.0.13.3 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
friendlyfashion-thinking-sphinx-2.0.13.2 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
friendlyfashion-thinking-sphinx-2.0.13.1 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
friendlyfashion-thinking-sphinx-2.0.13 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
thinking-sphinx-2.0.13 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
thinking-sphinx-2.0.12 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
thinking-sphinx-2.0.11 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
thinking-sphinx-2.0.10 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
thinking-sphinx-2.0.9 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb
thinking-sphinx-2.0.8 lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb