Class: ThinkingSphinx::FacetSearch::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/facet_search.rb

Instance Method Summary collapse

Constructor Details

#initialize(facets, hash) ⇒ Filter

Returns a new instance of Filter



126
127
128
# File 'lib/thinking_sphinx/facet_search.rb', line 126

def initialize(facets, hash)
  @facets, @hash = facets, hash
end

Instance Method Details

#to_hashObject



130
131
132
133
134
135
136
137
# File 'lib/thinking_sphinx/facet_search.rb', line 130

def to_hash
  @hash.keys.inject({}) { |options, key|
    type = @facets.detect { |facet| facet.name == key.to_s }.filter_type
    options[type] ||= {}
    options[type][key] = @hash[key]
    options
  }
end