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