Sha256: 2c12fd9e15f2f90e61af670b7c0138612c759b2399f3db8a872993e4e762bdc0

Contents?: true

Size: 653 Bytes

Versions: 7

Compression:

Stored size: 653 Bytes

Contents

# encoding: utf-8
class ThinkingSphinx::Search::Query
  attr_reader :keywords, :conditions, :star

  def initialize(keywords = '', conditions = {}, star = false)
    @keywords, @conditions, @star = keywords, conditions, star
  end

  def to_s
    (star_keyword(keywords || '') + ' ' + conditions.keys.collect { |key|
       next if conditions[key].blank?

      "@#{key} #{star_keyword conditions[key], key}"
    }.join(' ')).strip
  end

  private

  def star_keyword(keyword, key = nil)
    return keyword.to_s unless star
    return keyword.to_s if key.to_s == 'sphinx_internal_class_name'

    ThinkingSphinx::Query.wildcard keyword, star
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
thinking-sphinx-3.3.0 lib/thinking_sphinx/search/query.rb
thinking-sphinx-3.2.0 lib/thinking_sphinx/search/query.rb
thinking-sphinx-3.1.4 lib/thinking_sphinx/search/query.rb
thinking-sphinx-3.1.3 lib/thinking_sphinx/search/query.rb
thinking-sphinx-3.1.2 lib/thinking_sphinx/search/query.rb
thinking-sphinx-3.1.1 lib/thinking_sphinx/search/query.rb
thinking-sphinx-3.1.0 lib/thinking_sphinx/search/query.rb