class WinewooCore::Repositories::Mongo::CommentsMongoRepo
Public Instance Methods
create(winewoo_user, wine_id, vintage_id, comment_params)
click to toggle source
# File lib/winewoo_core/repositories/mongo/comments_mongo_repo.rb, line 21 def create(winewoo_user, wine_id, vintage_id, comment_params) return unless (wine_id && vintage_id) wine = Wine.find(wine_id) return unless wine vintage = wine.vintages.find(vintage_id) return unless vintage comment = UserComment.create(comment_params) comment.vintage = vintage comment.winewoo_user = winewoo_user comment.wine = wine comment.save return comment end
destroy(wine_id, vintage_id, comment_id)
click to toggle source
# File lib/winewoo_core/repositories/mongo/comments_mongo_repo.rb, line 49 def destroy(wine_id, vintage_id, comment_id) return unless (wine_id && vintage_id && comment_id) wine = Wine.find(wine_id) return unless wine vintage = wine.vintages.find(vintage_id) return unless vintage comment = vintage.user_comments.find(comment_id) return unless comment comment.destroy return comment end
find(current_winewoo_user, wine_id, vintage_id, winewoo_user_id, filters)
click to toggle source
# File lib/winewoo_core/repositories/mongo/comments_mongo_repo.rb, line 14 def find(current_winewoo_user, wine_id, vintage_id, winewoo_user_id, filters) return WinewooCore::Services::Finders::Comments::CommentsFinderBuilder .build(current_winewoo_user, wine_id, vintage_id, winewoo_user_id, filters) .find end
show(wine_id, vintage_id, comment_id)
click to toggle source
# File lib/winewoo_core/repositories/mongo/comments_mongo_repo.rb, line 4 def show(wine_id, vintage_id, comment_id) return unless (wine_id && vintage_id && comment_id) wine = Wine.find(wine_id) return unless wine vintage = wine.vintages.find(vintage_id) return unless vintage vintage.user_comments.find(comment_id) end
update(wine_id, vintage_id, comment_id, comment_params)
click to toggle source
# File lib/winewoo_core/repositories/mongo/comments_mongo_repo.rb, line 36 def update(wine_id, vintage_id, comment_id, comment_params) return unless (wine_id && vintage_id && comment_id) wine = Wine.find(wine_id) return unless wine vintage = wine.vintages.find(vintage_id) return unless vintage comment = vintage.user_comments.find(comment_id) return unless comment comment.update_attributes(comment_params) return comment end