Module: Workarea::Admin::CommentableViewModel
- Included in:
- AssetViewModel, CategoryViewModel, ContentViewModel, DiscountViewModel, OrderViewModel, PageViewModel, ProductViewModel, ReleaseViewModel, SearchCustomizationViewModel, SegmentViewModel, UserViewModel
- Defined in:
- app/view_models/workarea/admin/commentable_view_model.rb
Instance Method Summary collapse
- #comment_count ⇒ Object
- #comments ⇒ Object
- #has_comments? ⇒ Boolean
- #new_comments_for?(user) ⇒ Boolean
- #subscribed_users ⇒ Object
Instance Method Details
#comment_count ⇒ Object
12 13 14 |
# File 'app/view_models/workarea/admin/commentable_view_model.rb', line 12 def comment_count @comment_count ||= comments.count end |
#comments ⇒ Object
16 17 18 |
# File 'app/view_models/workarea/admin/commentable_view_model.rb', line 16 def comments @comments ||= CommentViewModel.wrap(model.comments) end |
#has_comments? ⇒ Boolean
4 5 6 |
# File 'app/view_models/workarea/admin/commentable_view_model.rb', line 4 def has_comments? comment_count > 0 end |
#new_comments_for?(user) ⇒ Boolean
8 9 10 |
# File 'app/view_models/workarea/admin/commentable_view_model.rb', line 8 def new_comments_for?(user) comments.any? { |c| !user.id.in?(c.viewed_by_ids) } end |
#subscribed_users ⇒ Object
20 21 22 |
# File 'app/view_models/workarea/admin/commentable_view_model.rb', line 20 def subscribed_users @users ||= User.in(id: subscribed_user_ids) end |