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



23
24
25
# File 'decidim-comments/lib/decidim/api/commentable_interface.rb', line 23

def comments(order_by: nil, single_comment_id: nil)
  SortedComments.for(object, order_by:, id: single_comment_id).not_hidden
end

#has_commentsObject

rubocop:disable Naming/PredicateName



28
29
30
# File 'decidim-comments/lib/decidim/api/commentable_interface.rb', line 28

def has_comments
  object.comment_threads.not_hidden.size.positive?
end

#user_allowed_to_commentObject

rubocop:enable Naming/PredicateName



33
34
35
# File 'decidim-comments/lib/decidim/api/commentable_interface.rb', line 33

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