Class: Decidim::Debates::DebateSerializer

Inherits:
Exporters::Serializer
  • Object
show all
Includes:
ApplicationHelper, ResourceHelper
Defined in:
lib/decidim/debates/debate_serializer.rb

Overview

This class serializes a Debate so can be exported to CSV, JSON or other formats.

Direct Known Subclasses

DownloadYourDataDebateSerializer

Instance Method Summary collapse

Instance Method Details

#serializeObject

Public: Exports a hash with the serialized data for this resource.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/decidim/debates/debate_serializer.rb', line 12

def serialize
  {
    id: resource.id,
    author: {
      **author_fields
    },
    title: resource.title,
    description: resource.description,
    instructions: resource.instructions,
    start_time: resource.start_time,
    end_time: resource.end_time,
    information_updates: resource.information_updates,
    taxonomies:,
    participatory_space: {
      id: resource.participatory_space.id,
      url: Decidim::ResourceLocatorPresenter.new(resource.participatory_space).url
    },
    component: { id: component.id },
    reference: resource.reference,
    comments: resource.comments_count,
    follows_count: resource.follows_count,
    url: Decidim::ResourceLocatorPresenter.new(resource).url,
    last_comment_at: resource.last_comment_at,
    last_comment_by: {
      **last_comment_by_fields
    },
    comments_enabled: resource.comments_enabled,
    conclusions: resource.conclusions,
    closed_at: resource.closed_at,
    created_at: resource.created_at,
    updated_at: resource.updated_at,
    endorsements_count: resource.endorsements_count
  }
end