Class: Decidim::Comments::CommentType
- Inherits:
-
Api::Types::BaseObject
- Object
- Api::Types::BaseObject
- Decidim::Comments::CommentType
- Defined in:
- lib/decidim/api/comment_type.rb
Overview
This type represents a comment on a commentable object.
Instance Method Summary collapse
- #already_reported ⇒ Object
- #author ⇒ Object
- #body ⇒ Object
- #created_at ⇒ Object
- #down_voted ⇒ Object
- #down_votes ⇒ Object
- #formatted_created_at ⇒ Object
- #has_comments? ⇒ Boolean
- #sgid ⇒ Object
- #up_voted ⇒ Object
- #up_votes ⇒ Object
- #user_allowed_to_comment ⇒ Object
Instance Method Details
#already_reported ⇒ Object
80 81 82 |
# File 'lib/decidim/api/comment_type.rb', line 80 def already_reported object.reported_by?(context[:current_user]) end |
#author ⇒ Object
40 41 42 |
# File 'lib/decidim/api/comment_type.rb', line 40 def object.user_group || object. end |
#body ⇒ Object
48 49 50 |
# File 'lib/decidim/api/comment_type.rb', line 48 def body object.translated_body end |
#created_at ⇒ Object
52 53 54 |
# File 'lib/decidim/api/comment_type.rb', line 52 def created_at object.created_at.iso8601 end |
#down_voted ⇒ Object
72 73 74 |
# File 'lib/decidim/api/comment_type.rb', line 72 def down_voted object.down_voted_by?(context[:current_user]) end |
#down_votes ⇒ Object
68 69 70 |
# File 'lib/decidim/api/comment_type.rb', line 68 def down_votes object.down_votes.size end |
#formatted_created_at ⇒ Object
56 57 58 |
# File 'lib/decidim/api/comment_type.rb', line 56 def formatted_created_at object.friendly_created_at end |
#has_comments? ⇒ Boolean
76 77 78 |
# File 'lib/decidim/api/comment_type.rb', line 76 def has_comments? object.comment_threads.not_hidden.size.positive? end |
#sgid ⇒ Object
44 45 46 |
# File 'lib/decidim/api/comment_type.rb', line 44 def sgid object.to_sgid.to_s end |
#up_voted ⇒ Object
64 65 66 |
# File 'lib/decidim/api/comment_type.rb', line 64 def up_voted object.up_voted_by?(context[:current_user]) end |
#up_votes ⇒ Object
60 61 62 |
# File 'lib/decidim/api/comment_type.rb', line 60 def up_votes object.up_votes.size end |
#user_allowed_to_comment ⇒ Object
84 85 86 |
# File 'lib/decidim/api/comment_type.rb', line 84 def user_allowed_to_comment object.root_commentable.commentable? && object.root_commentable.user_allowed_to_comment?(context[:current_user]) end |