diff options
Diffstat (limited to 'app/queries')
-rw-r--r-- | app/queries/reviews/has_user_already_posted_review_query.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/queries/reviews/has_user_already_posted_review_query.rb b/app/queries/reviews/has_user_already_posted_review_query.rb new file mode 100644 index 0000000..182f12e --- /dev/null +++ b/app/queries/reviews/has_user_already_posted_review_query.rb @@ -0,0 +1,14 @@ +# frozen_string_literal + +module Reviews + # HasUserAlreadyPostedReviewQuery + class HasUserAlreadyPostedReviewQuery + def initialize(product) + @product = product + end + + def review_posted?(user_account_id) + ProductReview.find_by(user_account_id:, product_id: @product.id).present? + end + end +end |