Class: Decidim::Meetings::DownloadYourDataUserAnswersSerializer

Inherits:
Exporters::Serializer show all
Includes:
TranslationsHelper
Defined in:
decidim-meetings/lib/decidim/meetings/download_your_data_user_answers_serializer.rb

Instance Attribute Summary

Attributes inherited from Exporters::Serializer

#resource

Instance Method Summary collapse

Methods included from TranslationsHelper

empty_translatable, ensure_translatable, multi_translation, translated_in_current_locale?

Methods included from TranslatableAttributes

#default_locale?

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 an user answer for download your data


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'decidim-meetings/lib/decidim/meetings/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
    },
    question: {
      id: resource.question.id,
      body: translated_attribute(resource.question.body)
    },
    answer: normalize_body(resource)
  }
end