Class: Wines::RemoveWine

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

Instance Method Summary collapse

Constructor Details

#initialize(current_user) ⇒ RemoveWine

Returns a new instance of RemoveWine.



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

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

Instance Method Details

#call(wine_id) {|wine ? UseCaseResults.success(wine) : UseCaseResults.not_found| ... } ⇒ Object

Yields:



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

def call(wine_id)
  wine = self.repo.get(wine_id)
  return unless authorize_wine_remove(wine, &Proc.new)

  wine = self.repo.destroy(self.current_caller, wine_id)

  yield wine ?
    UseCaseResults.success(wine) :
    UseCaseResults.not_found
end