Class: WinewooUser::Favorites::RemoveFavorite

Inherits:
BaseUseCase
  • Object
show all
Defined in:
lib/winewoo_core/use_cases/winewoo_user/favorites/remove_favorite.rb

Instance Method Summary collapse

Constructor Details

#initialize(log_params = nil) ⇒ RemoveFavorite

Returns a new instance of RemoveFavorite.



4
5
6
# File 'lib/winewoo_core/use_cases/winewoo_user/favorites/remove_favorite.rb', line 4

def initialize(log_params=nil)
  super(WinewooCore.favorites_repo.new, log_params)
end

Instance Method Details

#call(winewoo_user, favorite_id) {|favorite ? UseCaseResults.success(favorite) : UseCaseResults.not_found| ... } ⇒ Object

Yields:



9
10
11
12
13
14
15
16
# File 'lib/winewoo_core/use_cases/winewoo_user/favorites/remove_favorite.rb', line 9

def call(winewoo_user, favorite_id)
  favorite = self.repo.destroy(winewoo_user, favorite_id)
  self.log_repo.create(complete_log_params(favorite)) if favorite

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