Class: Decidim::Comments::CommentType
Overview
This type represents a comment on a commentable object.
Class Method Summary
collapse
Instance Method Summary
collapse
allowed_to?, determine_subject_name, local_context, permission_chain
Class Method Details
.authorized?(object, context) ⇒ Boolean
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'decidim-comments/lib/decidim/api/comment_type.rb', line 51
def self.authorized?(object, context)
chain = []
if object.respond_to?(:commentable) && !object..is_a?(Decidim::Comments::Comment)
chain.unshift(allowed_to?(:read, object., object.,
context))
end
chain.unshift(!object.hidden?)
chain.unshift(!object.deleted?)
super && chain.all?
end
|
Instance Method Details
#already_reported ⇒ Object
43
44
45
|
# File 'decidim-comments/lib/decidim/api/comment_type.rb', line 43
def already_reported
object.reported_by?(context[:current_user])
end
|
#down_voted ⇒ Object
35
36
37
|
# File 'decidim-comments/lib/decidim/api/comment_type.rb', line 35
def down_voted
object.down_voted_by?(context[:current_user])
end
|
39
40
41
|
# File 'decidim-comments/lib/decidim/api/comment_type.rb', line 39
def
object..not_hidden.size.positive?
end
|
#sgid ⇒ Object
27
28
29
|
# File 'decidim-comments/lib/decidim/api/comment_type.rb', line 27
def sgid
object.to_sgid.to_s
end
|
#up_voted ⇒ Object
31
32
33
|
# File 'decidim-comments/lib/decidim/api/comment_type.rb', line 31
def up_voted
object.up_voted_by?(context[:current_user])
end
|
47
48
49
|
# File 'decidim-comments/lib/decidim/api/comment_type.rb', line 47
def
object.. && object..(context[:current_user])
end
|