Class: Decidim::Comments::CommentVoteSerializer

Inherits:
Exporters::Serializer show all
Includes:
ResourceHelper
Defined in:
decidim-comments/lib/decidim/comments/comment_vote_serializer.rb

Instance Attribute Summary

Attributes inherited from Exporters::Serializer

#resource

Instance Method Summary collapse

Methods included from ResourceHelper

#linked_classes_filter_values_for, #linked_classes_for, #resource_locator, #resource_title

Methods inherited from Exporters::Serializer

#event_name, #finalize, #initialize, #run

Constructor Details

This class inherits a constructor from Decidim::Exporters::Serializer

Instance Method Details

#serializeObject

Serializes a comment



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'decidim-comments/lib/decidim/comments/comment_vote_serializer.rb', line 9

def serialize
  {
    id: resource.id,
    weight: resource.weight,
    comment: {
      id: resource.comment.id,
      created_at: resource.comment.created_at,
      body: resource.comment.body,
      author: {
        id: resource.comment.author.id,
        name: resource.comment.author.name
      },
      alignment: resource.comment.alignment,
      depth: resource.comment.depth,
      user_group: {
        id: resource.comment.user_group.try(:id),
        name: resource.comment.user_group.try(:name)
      },
      commentable_id: resource.comment.decidim_commentable_id,
      commentable_type: resource.comment.decidim_commentable_type,
      root_commentable_url:

    },
    created_at: resource.created_at,
    updated_at: resource.updated_at
  }
end