module Decidim::Comments::CommentableInterface

This interface represents a commentable object.

Public Instance Methods

comments(order_by: nil, single_comment_id: nil) click to toggle source
# File lib/decidim/api/commentable_interface.rb, line 27
def comments(order_by: nil, single_comment_id: nil)
  SortedComments.for(object, order_by: order_by, id: single_comment_id)
end
has_comments() click to toggle source

rubocop:disable Naming/PredicateName

# File lib/decidim/api/commentable_interface.rb, line 38
def has_comments
  object.comment_threads.size.positive?
end
total_comments_count() click to toggle source
# File lib/decidim/api/commentable_interface.rb, line 31
def total_comments_count
  object.comments_count
end
user_allowed_to_comment() click to toggle source
# File lib/decidim/api/commentable_interface.rb, line 45
def user_allowed_to_comment
  object.commentable? && object.user_allowed_to_comment?(context[:current_user])
end