Class: Decidim::Exporters::OpenDataModerationSerializer

Inherits:
Serializer
  • Object
show all
Defined in:
decidim-core/app/serializers/decidim/exporters/open_data_moderation_serializer.rb

Instance Attribute Summary

Attributes inherited from Serializer

#resource

Instance Method Summary collapse

Methods inherited from Serializer

#event_name, #finalize, #run

Constructor Details

#initialize(resource) ⇒ OpenDataModerationSerializer

Public: Initializes the serializer with a resource



7
8
9
# File 'decidim-core/app/serializers/decidim/exporters/open_data_moderation_serializer.rb', line 7

def initialize(resource)
  @resource = resource
end

Instance Method Details

#serializeObject

Public: Exports a hash with the serialized data for this resource.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'decidim-core/app/serializers/decidim/exporters/open_data_moderation_serializer.rb', line 12

def serialize
  {
    id: resource.id,
    hidden_at: resource.hidden_at,
    report_count: resource.report_count,
    reported_url: resource.reportable.reported_content_url,
    reportable_type: resource.decidim_reportable_type,
    reportable_id: resource.decidim_reportable_id,
    reported_content: resource.reported_content,
    reports: {
      reasons: resource.reports.map(&:reason),
      locale: resource.reports.map(&:locale),
      details: resource.reports.map(&:details)
    }
  }
end