Module: Workarea::Admin::CommentableViewModel

Instance Method Summary collapse

Instance Method Details

#comment_countObject



12
13
14
# File 'app/view_models/workarea/admin/commentable_view_model.rb', line 12

def comment_count
  @comment_count ||= comments.count
end

#commentsObject



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

Returns:

  • (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

Returns:

  • (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_usersObject



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