class Decidim::Meetings::MeetingSerializer
This class serializes a Meeting so can be exported to CSV, JSON or other formats.
Attributes
meeting[R]
Public Class Methods
new(meeting)
click to toggle source
Public: Initializes the serializer with a meeting.
# File lib/decidim/meetings/meeting_serializer.rb, line 12 def initialize(meeting) @meeting = meeting end
Public Instance Methods
serialize()
click to toggle source
Public: Exports a hash with the serialized data for this meeting.
# File lib/decidim/meetings/meeting_serializer.rb, line 17 def serialize { id: meeting.id, category: { id: meeting.category.try(:id), name: meeting.category.try(:name) }, scope: { id: meeting.scope.try(:id), name: meeting.scope.try(:name) }, participatory_space: { id: meeting.participatory_space.id, url: Decidim::ResourceLocatorPresenter.new(meeting.participatory_space).url }, component: { id: component.id }, title: meeting.title, description: meeting.description, start_time: meeting.start_time.to_s(:db), end_time: meeting.end_time.to_s(:db), attendees: meeting.attendees_count.to_i, contributions: meeting.contributions_count.to_i, organizations: meeting.attending_organizations, address: meeting.address, location: meeting.location, reference: meeting.reference, comments: meeting.comments_count, attachments: meeting.attachments.count, followers: meeting.followers.count, url: url, related_proposals: related_proposals, related_results: related_results } end
Private Instance Methods
component()
click to toggle source
# File lib/decidim/meetings/meeting_serializer.rb, line 56 def component meeting.component end
url()
click to toggle source
# File lib/decidim/meetings/meeting_serializer.rb, line 72 def url Decidim::ResourceLocatorPresenter.new(meeting).url end