Class: Decidim::Votings::VotingSerializer
- Inherits:
-
Exporters::Serializer
- Object
- Exporters::Serializer
- Decidim::Votings::VotingSerializer
- Includes:
- ApplicationHelper, ResourceHelper, TranslationsHelper
- Defined in:
- lib/decidim/votings/voting_serializer.rb
Overview
This class serializes a Voting so it can be exported to CSV, JSON or other formats.
Instance Method Summary collapse
-
#initialize(voting) ⇒ VotingSerializer
constructor
Public: Initializes the serializer with a voting.
-
#serialize ⇒ Object
Public: Exports a hash with the serialized data for this voting.
Constructor Details
#initialize(voting) ⇒ VotingSerializer
Public: Initializes the serializer with a voting.
13 14 15 |
# File 'lib/decidim/votings/voting_serializer.rb', line 13 def initialize(voting) @voting = voting end |
Instance Method Details
#serialize ⇒ Object
Public: Exports a hash with the serialized data for this voting.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/decidim/votings/voting_serializer.rb', line 18 def serialize { participatory_space_id: voting.id, url:, title: voting.title, description: voting.description, start_time: voting.start_time, end_time: voting.end_time, voting_type: translated_voting_type, scope: { id: voting.scope.try(:id), name: voting.scope.try(:name) }, banner_image_url: Decidim::Votings::VotingPresenter.new(voting)., introductory_image_url: Decidim::Votings::VotingPresenter.new(voting).introductory_image_url } end |