Class: WinewooUser::Cellar::UpdateCellarEntry

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

Instance Method Summary collapse

Constructor Details

#initialize(log_params = nil) ⇒ UpdateCellarEntry

Returns a new instance of UpdateCellarEntry.



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

Yields:



9
10
11
12
13
14
15
16
17
18
# File 'lib/winewoo_core/use_cases/winewoo_user/cellar/update_cellar_entry.rb', line 9

def call(winewoo_user, entry_id, entry_params)
  entry = self.repo.update(winewoo_user, entry_id, entry_params)
  self.log_repo.create(complete_log_params(entry)) if entry && entry.errors.blank?

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