Class: Decidim::Comments::CommentSerializer

Inherits:
Exporters::Serializer
  • Object
show all
Includes:
ResourceHelper, TranslationsHelper
Defined in:
lib/decidim/comments/comment_serializer.rb

Instance Method Summary collapse

Instance Method Details

#serializeObject

Serializes a comment



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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.try(:id),
      name: resource.author.try(:name)
    },
    alignment: resource.alignment,
    depth: resource.depth,
    commentable_id: resource.decidim_commentable_id,
    commentable_type: resource.decidim_commentable_type,
    root_commentable_url:
  }
end