Module: DynamicSunspotSearch::Translator::Facet
- Defined in:
- lib/dynamic_sunspot_search/translator/facet.rb
Class Method Summary collapse
Class Method Details
.apply(query_object, options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/dynamic_sunspot_search/translator/facet.rb', line 7 def self.apply(query_object, ) return unless .present? query_object.tap do |search| case when String, Symbol, Array search.facet * when Hash fields = .values_at(:field, :fields).flatten.compact exclude_filter = get_exclude_filter(search, .delete(:exclude)) search.facet(*fields, exclude: exclude_filter) else raise NotImplementedError end end end |
.get_exclude_filter(query_object, options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dynamic_sunspot_search/translator/facet.rb', line 23 def self.get_exclude_filter(query_object, ) case when Array .map do |option| get_exclude_filter(query_object, option) end.flatten when Hash [ With.apply(query_object, .delete(:with)), Without.apply(query_object, .delete(:without)), ].flatten.compact else raise NotImplementedError end end |