Class: WinewooUser::Comments::UpdateComment

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

Instance Method Summary collapse

Constructor Details

#initialize(log_params = nil) ⇒ UpdateComment

Returns a new instance of UpdateComment.



4
5
6
# File 'lib/winewoo_core/use_cases/winewoo_user/comments/update_comment.rb', line 4

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

Instance Method Details

#call(wine_id, vintage_id, comment_id, comment_params) {|comment ? (comment.errors.blank? ? UseCaseResults.success(comment) : UseCaseResults.failure(comment.errors)) : UseCaseResults.not_found| ... } ⇒ Object

Yields:



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/winewoo_core/use_cases/winewoo_user/comments/update_comment.rb', line 9

def call(wine_id, vintage_id, comment_id, comment_params)
  comment = self.repo.update(wine_id,
                           vintage_id,
                           comment_id,
                           comment_params)

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