Sha256: 5155a6572369128c38afd30a84b6ac7bf9e04ae318ee091012a40ec473d4a0a7

Contents?: true

Size: 962 Bytes

Versions: 6

Compression:

Stored size: 962 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Initiatives
    class InitiativeSerializer < Decidim::Exporters::Serializer
      # Serializes an initiative
      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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-initiatives-0.29.1 app/serializers/decidim/initiatives/initiative_serializer.rb
decidim-initiatives-0.29.0 app/serializers/decidim/initiatives/initiative_serializer.rb
decidim-initiatives-0.29.0.rc4 app/serializers/decidim/initiatives/initiative_serializer.rb
decidim-initiatives-0.29.0.rc3 app/serializers/decidim/initiatives/initiative_serializer.rb
decidim-initiatives-0.29.0.rc2 app/serializers/decidim/initiatives/initiative_serializer.rb
decidim-initiatives-0.29.0.rc1 app/serializers/decidim/initiatives/initiative_serializer.rb