Class: Wines::UpdateAward
- Inherits:
-
BaseUseCase
- Object
- BaseUseCase
- Wines::UpdateAward
- Defined in:
- lib/winewoo_core/use_cases/wines/update_award.rb
Instance Method Summary collapse
- #call(wine_id, vintage_id, awards_params) {|award ? (award.errors.blank? ? UseCaseResults.success(award) : UseCaseResults.failure(award.errors)) : UseCaseResults.not_found| ... } ⇒ Object
-
#initialize(current_user) ⇒ UpdateAward
constructor
A new instance of UpdateAward.
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
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 (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 |