Class: Decidim::Elections::AnswerSerializer
- Inherits:
-
Decidim::Exporters::Serializer
- Object
- Decidim::Exporters::Serializer
- Decidim::Elections::AnswerSerializer
- Includes:
- ApplicationHelper, ResourceHelper, TranslationsHelper
- Defined in:
- lib/decidim/elections/answer_serializer.rb
Overview
This class serializes an Answer so it can be exported to CSV, JSON or other formats.
Instance Method Summary collapse
-
#initialize(answer) ⇒ AnswerSerializer
constructor
Public: Initializes the serializer with an answer.
-
#serialize ⇒ Object
Public: Exports a hash with the serialized data for this answer.
Constructor Details
#initialize(answer) ⇒ AnswerSerializer
Public: Initializes the serializer with an answer.
13 14 15 |
# File 'lib/decidim/elections/answer_serializer.rb', line 13 def initialize(answer) @answer = answer end |
Instance Method Details
#serialize ⇒ Object
Public: Exports a hash with the serialized data for this answer.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/decidim/elections/answer_serializer.rb', line 18 def serialize { participatory_space: { id: election.participatory_space.id, title: election.participatory_space.title }, id: answer.id, election_id: election.id, election_title: election.title, question_id: question.id, question_title: question.title, answer_id: answer.id, answer_title: answer.title, answer_votes: answer.results_total } end |