Class: Decidim::Forms::DownloadYourDataUserAnswersSerializer

Inherits:
Exporters::Serializer
  • Object
show all
Includes:
TranslationsHelper
Defined in:
lib/decidim/forms/download_your_data_user_answers_serializer.rb

Instance Method Summary collapse

Instance Method Details

#serializeObject

Serializes an user answer for download your data



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/decidim/forms/download_your_data_user_answers_serializer.rb', line 8

def serialize
  {
    id: resource.id,
    user: {
      name: resource.user.name,
      email: resource.user.email
    },
    questionnaire: {
      id: resource.question.questionnaire.id,
      title: translated_attribute(resource.question.questionnaire.title),
      description: translated_attribute(resource.question.questionnaire.description),
      tos: translated_attribute(resource.question.questionnaire.tos)
    },
    question: {
      id: resource.question.id,
      body: translated_attribute(resource.question.body),
      description: translated_attribute(resource.question.description)
    },
    answer: normalize_body(resource)
  }
end