Class: Decidim::Initiatives::InitiativeSerializer

Inherits:
Exporters::Serializer show all
Defined in:
decidim-initiatives/app/serializers/decidim/initiatives/initiative_serializer.rb

Instance Attribute Summary

Attributes inherited from Exporters::Serializer

#resource

Instance Method Summary collapse

Methods inherited from Exporters::Serializer

#event_name, #finalize, #initialize, #run

Constructor Details

This class inherits a constructor from Decidim::Exporters::Serializer

Instance Method Details

#serializeObject

Serializes an inititative



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'decidim-initiatives/app/serializers/decidim/initiatives/initiative_serializer.rb', line 7

def serialize
  {
    id: resource.id,
    title: resource.title,
    description: resource.description,
    state: resource.state,
    created_at: resource.created_at,
    published_at: resource.published_at,
    signature_end_date: resource.signature_end_date,
    signature_type: resource.signature_type,
    signatures: resource.supports_count,
    scope: {
      name: resource.scope&.name
    },
    type: {
      title: resource.type&.title
    },
    authors: {
      id: resource.author_users.map(&:id),
      name: resource.author_users.map(&:name)
    },
    area: {
      name: resource.area&.name
    }
  }
end