Sha256: 9d59346ebb16ac958444f2c7cc483a59ce310436f5be8cae44f6790471c14d81
Contents?: true
Size: 1.36 KB
Versions: 7
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true module Decidim module Comments class CommentSerializer < Decidim::Exporters::Serializer include Decidim::ResourceHelper include Decidim::TranslationsHelper # Serializes a comment def serialize { id: resource.id, created_at: resource.created_at, body: resource.body.values.first, locale: resource.body.keys.first, author: { id: resource.author.id, name: resource.author.name }, alignment: resource.alignment, depth: resource.depth, user_group: { id: resource.user_group.try(:id), name: resource.user_group.try(:name) || empty_translatable }, commentable_id: resource.decidim_commentable_id, commentable_type: resource.decidim_commentable_type, root_commentable_url: root_commentable_url } end private def root_commentable_url @root_commentable_url ||= if resource.root_commentable.respond_to?(:polymorphic_resource_url) resource.root_commentable.polymorphic_resource_url else ResourceLocatorPresenter.new(resource.root_commentable).url end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems