Class: Wines::UpdateAward

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

Instance Method Summary collapse

Constructor Details

#initialize(current_user) ⇒ UpdateAward

Returns a new instance of UpdateAward.



4
5
6
7
# File 'lib/winewoo_core/use_cases/wines/update_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, awards_params) {|award ? (award.errors.blank? ? UseCaseResults.success(award) : UseCaseResults.failure(award.errors)) : UseCaseResults.not_found| ... } ⇒ Object

Yields:



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

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

  award = self.repo.update(wine_id, vintage_id, awards_params)

  yield award ?
    (award.errors.blank? ?
     UseCaseResults.success(award) :
     UseCaseResults.failure(award.errors)) :
    UseCaseResults.not_found
end