Class: WinewooUser::Comments::CreateComment
- Inherits:
-
BaseUseCase
- Object
- BaseUseCase
- WinewooUser::Comments::CreateComment
- Defined in:
- lib/winewoo_core/use_cases/winewoo_user/comments/create_comment.rb
Instance Method Summary collapse
- #call(winewoo_user, wine_id, vintage_id, comment_params, enable_indexation) ⇒ Object
-
#initialize(log_params = nil) ⇒ CreateComment
constructor
A new instance of CreateComment.
Constructor Details
#initialize(log_params = nil) ⇒ CreateComment
Returns a new instance of CreateComment.
4 5 6 |
# File 'lib/winewoo_core/use_cases/winewoo_user/comments/create_comment.rb', line 4 def initialize(log_params=nil) super(WinewooCore.comments_repo.new, log_params) end |
Instance Method Details
#call(winewoo_user, wine_id, vintage_id, comment_params, enable_indexation) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/winewoo_core/use_cases/winewoo_user/comments/create_comment.rb', line 9 def call(winewoo_user, wine_id, vintage_id, comment_params, enable_indexation) comment = self.repo.create(winewoo_user, wine_id, vintage_id, comment_params) if comment if comment.persisted? log = self.log_repo.create(complete_log_params(comment)) WinewooCore.feed_repo.new.create(log) if enable_indexation end yield comment.persisted? ? UseCaseResults.success(comment) : UseCaseResults.failure(comment.errors) else yield UseCaseResults.not_found end end |