Class: Wines::RemoveAward

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

Instance Method Summary collapse

Constructor Details

#initialize(current_user) ⇒ RemoveAward

Returns a new instance of RemoveAward.



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

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

Instance Method Details

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

Yields:



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

def call(wine_id, vintage_id)
  wine = WinewooCore.wines_repo.new.get(wine_id)
  return unless authorize_award_remove(wine, &Proc.new)

  award = self.repo.destroy(wine_id, vintage_id)

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