Sha256: 5ae644a11ddd5f3162b77f5d5202c87e185c0d7e051f69192fe3c3929f86d09d
Contents?: true
Size: 1.12 KB
Versions: 19
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true module Decidim # This class serializes a Message so can be exported to CSV module DataPortabilitySerializers class DataPortabilityConversationSerializer < Decidim::Exporters::Serializer include Decidim::ResourceHelper # Public: Initializes the serializer with a conversation. def initialize(conversation) @conversation = conversation end # Public: Exports a hash with the serialized data for this conversation. def serialize { id: conversation.id, messages: messages, created_at: conversation.created_at, updated_at: conversation.updated_at } end private attr_reader :conversation alias resource conversation def messages conversation.messages.map do |message| { message_id: message.id, sender_id: message.sender.id, sender_name: message.sender.name, body: message.body, created_at: message.created_at, updated_at: message.updated_at } end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems