class Decidim::Comments::CommentSerializer
Public Instance Methods
serialize()
click to toggle source
Serializes a comment
# File lib/decidim/comments/comment_serializer.rb, line 10 def serialize { id: resource.id, created_at: resource.created_at, body: resource.body.values.first, locale: resource.body.keys.first, author: { id: resource.author.id, name: resource.author.name }, alignment: resource.alignment, depth: resource.depth, user_group: { id: resource.user_group.try(:id), name: resource.user_group.try(:name) || empty_translatable }, commentable_id: resource.decidim_commentable_id, commentable_type: resource.decidim_commentable_type, root_commentable_url: root_commentable_url } end
Private Instance Methods
root_commentable_url()
click to toggle source
# File lib/decidim/comments/comment_serializer.rb, line 34 def root_commentable_url @root_commentable_url ||= if resource.root_commentable&.respond_to?(:polymorphic_resource_url) resource.root_commentable.polymorphic_resource_url else ResourceLocatorPresenter.new(resource.root_commentable).url end end