Class: Decidim::ParticipatoryDocuments::MySuggestionSerializer

Inherits:
SuggestionSerializer
  • Object
show all
Defined in:
app/serializers/decidim/participatory_documents/my_suggestion_serializer.rb

Overview

This class serializes a Suggestion so can be exported to CSV, JSON or other formats.

Instance Method Summary collapse

Methods inherited from SuggestionSerializer

#initialize

Methods included from Admin::SuggestionHelper

#bulk_valuators_select, #humanize_suggestion_state, #icon_with_link_to_suggestion, #suggestion_content

Constructor Details

This class inherits a constructor from Decidim::ParticipatoryDocuments::SuggestionSerializer

Instance Method Details

#serializeObject

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



9
10
11
12
13
14
15
16
17
18
19
# File 'app/serializers/decidim/participatory_documents/my_suggestion_serializer.rb', line 9

def serialize
  {
    id: suggestion.id,
    body: suggestion_body(suggestion),
    author: suggestion.try(:normalized_author).try(:name),
    state: humanize_suggestion_state(suggestion.state),
    answer: answer_text(suggestion),
    section: section(suggestion),
    submitted_on: (suggestion)
  }
end