Class: WinewooCore::Repositories::Mongo::InterproCriterionsMongoRepo::PictosFinder

Inherits:
Finder
  • Object
show all
Defined in:
lib/winewoo_core/repositories/mongo/interpro_criterions_mongo_repo.rb

Instance Method Summary collapse

Constructor Details

#initialize(category, query_param) ⇒ PictosFinder

Returns a new instance of PictosFinder.



104
105
106
107
# File 'lib/winewoo_core/repositories/mongo/interpro_criterions_mongo_repo.rb', line 104

def initialize(category, query_param)
  super(query_param)
  @category = category
end

Instance Method Details

#findObject



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/winewoo_core/repositories/mongo/interpro_criterions_mongo_repo.rb', line 110

def find
  if @category == :colors
    colors = @filters.interpro.wine_data_element.wine_colors
    colors.map {|id| PictoElement.find(id) }
  else
    res = WinewooCore::Repositories::Mongo::Queries::PictoQuery.new.from_category(@category).by_name
    res = res.full_text_search @filters.query if @filters.query
    return res.page(@filters.page || 1)
      .per(@filters.per_page || Kaminari::config.default_per_page)
  end
end