Skip to content

Instantly share code, notes, and snippets.

@vinchi777
Created June 1, 2021 02:47
Show Gist options
  • Save vinchi777/bc52a14abb33d57d7238dcba0efd9157 to your computer and use it in GitHub Desktop.
Save vinchi777/bc52a14abb33d57d7238dcba0efd9157 to your computer and use it in GitHub Desktop.
asd
# frozen_string_literal: true
class MetrofoodProductSearch
include BaseService
include Filterable
attr_reader :repository, :relation, :current_user, :sort, :page, :filters
def initialize(current_user, sort, page, filters)
@repository = MetrofoodProductRepository.new
@relation = MetrofoodProduct
@current_user = current_user
@page = page
@sort = sort
@filters = filters || {}
end
def call
filter :by_user, current_user
filter :with_ids, filter_param(:id)
filter :with_metrofood_restaurant_ids, filter_param(:'metrofood_restaurant.id')
filter :with_statuses, filter_param(:status)
filter :with_created_at_between, filter_param(:'created_at:between')
sort
paginate
success search_result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment