Sha256: da87a7ff10477035a738a79f5c4ab5755c442d65fd5779365db46726ecc07702
Contents?: true
Size: 1.12 KB
Versions: 17
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 DownloadYourDataSerializers class DownloadYourDataConversationSerializer < 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:, 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
17 entries across 17 versions & 1 rubygems