Class: WinewooUser::Favorites::CreateFavorite
- Inherits:
-
BaseUseCase
- Object
- BaseUseCase
- WinewooUser::Favorites::CreateFavorite
- Defined in:
- lib/winewoo_core/use_cases/winewoo_user/favorites/create_favorite.rb
Instance Method Summary collapse
- #call(winewoo_user, favorite_params) {|favorite.persisted? ? UseCaseResults.success(favorite) : UseCaseResults.failure(favorite.errors)| ... } ⇒ Object
-
#initialize(log_params = nil) ⇒ CreateFavorite
constructor
A new instance of CreateFavorite.
Constructor Details
#initialize(log_params = nil) ⇒ CreateFavorite
Returns a new instance of CreateFavorite.
4 5 6 |
# File 'lib/winewoo_core/use_cases/winewoo_user/favorites/create_favorite.rb', line 4 def initialize(log_params=nil) super(WinewooCore.favorites_repo.new, log_params) end |
Instance Method Details
#call(winewoo_user, favorite_params) {|favorite.persisted? ? UseCaseResults.success(favorite) : UseCaseResults.failure(favorite.errors)| ... } ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/winewoo_core/use_cases/winewoo_user/favorites/create_favorite.rb', line 9 def call(winewoo_user, favorite_params) favorite = self.repo.create(winewoo_user, favorite_params) self.log_repo.create(complete_log_params(favorite)) if favorite.persisted? yield favorite.persisted? ? UseCaseResults.success(favorite) : UseCaseResults.failure(favorite.errors) end |