Module: Decidim::Comments::CommentableInterface
- Includes:
- Api::Types::BaseInterface
- Defined in:
- lib/decidim/api/commentable_interface.rb
Overview
This interface represents a commentable object.
Instance Method Summary collapse
- #comments(order_by: nil, single_comment_id: nil) ⇒ Object
-
#has_comments ⇒ Object
rubocop:disable Naming/PredicateName.
- #total_comments_count ⇒ Object
- #user_allowed_to_comment ⇒ Object
Instance Method Details
#comments(order_by: nil, single_comment_id: nil) ⇒ Object
27 28 29 |
# 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).not_hidden end |
#has_comments ⇒ Object
rubocop:disable Naming/PredicateName
38 39 40 |
# File 'lib/decidim/api/commentable_interface.rb', line 38 def has_comments object.comment_threads.not_hidden.size.positive? end |
#total_comments_count ⇒ Object
31 32 33 |
# File 'lib/decidim/api/commentable_interface.rb', line 31 def total_comments_count object.comments_count end |
#user_allowed_to_comment ⇒ Object
45 46 47 |
# 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 |