Class: Wines::RemoveWine
- Inherits:
-
BaseUseCase
- Object
- BaseUseCase
- Wines::RemoveWine
- Defined in:
- lib/winewoo_core/use_cases/wines/remove_wine.rb
Instance Method Summary collapse
- #call(wine_id) {|wine ? UseCaseResults.success(wine) : UseCaseResults.not_found| ... } ⇒ Object
-
#initialize(current_user) ⇒ RemoveWine
constructor
A new instance of RemoveWine.
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
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 (wine, &Proc.new) wine = self.repo.destroy(self.current_caller, wine_id) yield wine ? UseCaseResults.success(wine) : UseCaseResults.not_found end |