class ThinkingSphinx::Facet
Attributes
name[R]
Public Class Methods
new(name, properties)
click to toggle source
# File lib/thinking_sphinx/facet.rb, line 4 def initialize(name, properties) @name, @properties = name, properties end
Public Instance Methods
filter_type()
click to toggle source
# File lib/thinking_sphinx/facet.rb, line 8 def filter_type use_field? ? :conditions : :with end
results_from(raw)
click to toggle source
# File lib/thinking_sphinx/facet.rb, line 12 def results_from(raw) raw.inject({}) { |hash, row| hash[row[group_column]] = row[ThinkingSphinx::SphinxQL.count] hash } end
Private Instance Methods
group_column()
click to toggle source
# File lib/thinking_sphinx/facet.rb, line 21 def group_column @properties.any?(&:multi?) ? ThinkingSphinx::SphinxQL.group_by : name end
use_field?()
click to toggle source
# File lib/thinking_sphinx/facet.rb, line 25 def use_field? @properties.any? { |property| property.type.nil? || property.type == :string } end