Class: Decidim::Initiatives::InitiativeSerializer

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

Instance Method Summary collapse

Instance Method Details

#serializeObject

Serializes an initiative



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 '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