Sha256: 631f7acaa360c5fc9aad800e65de79446d5053ba1b41c8b22b7dd7cc05062270

Contents?: true

Size: 606 Bytes

Versions: 18

Compression:

Stored size: 606 Bytes

Contents

module ThinkingSphinx::Scopes
  extend ActiveSupport::Concern

  module ClassMethods
    def default_sphinx_scope(scope_name = nil)
      return @default_sphinx_scope unless scope_name

      @default_sphinx_scope = scope_name
    end

    def sphinx_scope(name, &block)
      sphinx_scopes[name] = block
    end

    def sphinx_scopes
      @sphinx_scopes ||= {}
    end

    private

    def method_missing(method, *args, &block)
      return super unless sphinx_scopes.keys.include?(method)

      query, options = sphinx_scopes[method].call(*args)
      search query, (options || {})
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
thinking-sphinx-3.4.2 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.4.1 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.4.0 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.3.0 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.2.0 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.1.4 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.1.3 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.1.2 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.1.1 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.1.0 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.0.6 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.0.5 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.0.4 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.0.3 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.0.2 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.0.1 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.0.0 lib/thinking_sphinx/scopes.rb
thinking-sphinx-3.0.0.rc lib/thinking_sphinx/scopes.rb