Module: Decidim::Comments::CommentableInterface

Includes:
Api::Types::BaseInterface
Defined in:
decidim-comments/lib/decidim/api/commentable_interface.rb

Overview

This interface represents a commentable object.

Instance Method Summary collapse

Instance Method Details

#comments(order_by: nil, single_comment_id: nil) ⇒ Object


27
28
29
# File 'decidim-comments/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_commentsObject

rubocop:disable Naming/PredicateName


38
39
40
# File 'decidim-comments/lib/decidim/api/commentable_interface.rb', line 38

def has_comments
  object.comment_threads.size.positive?
end

#total_comments_countObject


31
32
33
# File 'decidim-comments/lib/decidim/api/commentable_interface.rb', line 31

def total_comments_count
  object.comments_count
end

#user_allowed_to_commentObject


45
46
47
# File 'decidim-comments/lib/decidim/api/commentable_interface.rb', line 45

def user_allowed_to_comment
  object.commentable? && object.user_allowed_to_comment?(context[:current_user])
end