Class: Wines::ListWines

Inherits:
BaseUseCase
  • Object
show all
Defined in:
lib/winewoo_core/use_cases/wines/list_wines.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_user, log_params = nil) ⇒ ListWines

Returns a new instance of ListWines.



4
5
6
7
# File 'lib/winewoo_core/use_cases/wines/list_wines.rb', line 4

def initialize(current_user, log_params=nil)
  super(WinewooCore.wines_repo.new, log_params)
  self.current_caller = current_user
end

Instance Method Details

#call(filters) {|wines ? UseCaseResults.found(wines, total) : UseCaseResults.failure| ... } ⇒ Object

Yields:



10
11
12
13
14
15
16
17
18
19
# File 'lib/winewoo_core/use_cases/wines/list_wines.rb', line 10

def call(filters)
  return unless authorize_wines_index(&Proc.new)

  wines, action, total = self.repo.find(filters)
  log_search(action, filters.query, total)

  yield wines ?
    UseCaseResults.found(wines, total) :
    UseCaseResults.failure
end