Sha256: c263eb9c1b47f91ab42c153ed3178abb82662775841bec2b78238a966fb0cc1b

Contents?: true

Size: 816 Bytes

Versions: 25

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    class DownloadYourDataUserAnswersSerializer < Decidim::Exporters::Serializer
      include Decidim::TranslationsHelper
      # Serializes an user answer for download your data
      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

      private

      def normalize_body(resource)
        resource.choices.pluck(:body)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-meetings-0.29.1 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.28.4 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.27.9 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.29.0 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.28.3 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.27.8 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.29.0.rc4 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.29.0.rc3 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.29.0.rc2 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.29.0.rc1 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.28.2 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.27.7 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.28.1 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.27.6 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.28.0 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.27.5 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.28.0.rc5 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.28.0.rc4 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.27.4 lib/decidim/meetings/download_your_data_user_answers_serializer.rb
decidim-meetings-0.27.3 lib/decidim/meetings/download_your_data_user_answers_serializer.rb