Class: Decidim::Assemblies::AssemblySerializer
- Inherits:
-
Exporters::Serializer
- Object
- Exporters::Serializer
- Decidim::Assemblies::AssemblySerializer
- Includes:
- Decidim::ApplicationHelper, ResourceHelper, TranslationsHelper
- Defined in:
- app/serializers/decidim/assemblies/assembly_serializer.rb
Overview
This class serializes an Assembly so it can be exported to CSV, JSON or other formats.
Instance Method Summary collapse
-
#initialize(assembly) ⇒ AssemblySerializer
constructor
Public: Initializes the serializer with an Assembly instance.
-
#serialize ⇒ Object
Public: Exports a hash with the serialized data for this assembly.
Constructor Details
#initialize(assembly) ⇒ AssemblySerializer
Public: Initializes the serializer with an Assembly instance.
12 13 14 |
# File 'app/serializers/decidim/assemblies/assembly_serializer.rb', line 12 def initialize(assembly) @assembly = assembly end |
Instance Method Details
#serialize ⇒ Object
Public: Exports a hash with the serialized data for this assembly.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/serializers/decidim/assemblies/assembly_serializer.rb', line 17 def serialize { id: assembly.id, slug: assembly.slug, hashtag: assembly.hashtag, decidim_organization_id: assembly.decidim_organization_id, title: assembly.title, subtitle: assembly.subtitle, weight: assembly.weight, short_description: assembly.short_description, description: assembly.description, remote_hero_image_url: Decidim::Assemblies::AssemblyPresenter.new(assembly).hero_image_url, remote_banner_image_url: Decidim::Assemblies::AssemblyPresenter.new(assembly)., promoted: assembly.promoted, developer_group: assembly.developer_group, meta_scope: assembly., local_area: assembly.local_area, target: assembly.target, decidim_scope_id: assembly.decidim_scope_id, paticipatory_scope: assembly.participatory_scope, # intentionally misspelled participatory_structure: assembly.participatory_structure, scopes_enabled: assembly.scopes_enabled, private_space: assembly.private_space, reference: assembly.reference, purpose_of_action: assembly.purpose_of_action, composition: assembly.composition, duration: assembly.duration, participatory_scope: assembly.participatory_scope, included_at: assembly.included_at, closing_date: assembly.closing_date, created_by: assembly.created_by, creation_date: assembly.creation_date, closing_date_reason: assembly.closing_date_reason, internal_organisation: assembly.internal_organisation, is_transparent: assembly.is_transparent, special_features: assembly.special_features, twitter_handler: assembly.twitter_handler, instagram_handler: assembly.instagram_handler, facebook_handler: assembly.facebook_handler, youtube_handler: assembly.youtube_handler, github_handler: assembly.github_handler, created_by_other: assembly.created_by_other, decidim_assemblies_type_id: assembly.decidim_assemblies_type_id, area: { id: assembly.area.try(:id), name: assembly.area.try(:name) || empty_translatable }, scope: { id: assembly.scope.try(:id), name: assembly.scope.try(:name) || empty_translatable }, assembly_categories: serialize_categories, attachments: { attachment_collections: , files: }, components: serialize_components, announcement: assembly.announcement } end |