Class: WinewooCore::Services::Finders::Wines::WinesFinderBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/winewoo_core/services/finders/wines/wines_finder_builder.rb

Class Method Summary collapse

Class Method Details

.build(filters) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/winewoo_core/services/finders/wines/wines_finder_builder.rb', line 4

def self.build(filters)
  if filters.list_of_wines
    ListOfWinesFinder.new(filters)
  else
    if filters.top_wines
      TopWinesFinder.new(filters)
    else
      query = filters.query
      case query
      when nil
        if filters.producer
          ProducerWinesFinder.new(filters)
        elsif filters.interpro
          InterproWinesFinder.new(filters)
        else
          # NullWinesFinder.new
          AllWinesFinder.new(filters)
        end
      else
        Rails.logger.info "WINEWOO #{query} - #{filters.to_json}"
        query.is_a?(String) ?
          (filters.interpro ? KeywordsWinesFinder.new(filters) : ElasticsearchWinesFinder.new(filters)) :
          FiltersWinesFinder.new(filters)
      end
    end
  end
end