Sha256: 8ac020e0eda083b1301da29890c91ef3907587919d8d3700fa010422c2db8a71

Contents?: true

Size: 1.15 KB

Versions: 25

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    class DownloadYourDataBudgetsOrderSerializer < Decidim::Exporters::Serializer
      # Public: Initializes the serializer with a conversation.
      def initialize(order)
        @order = order
      end

      # Serializes a Debate for download your data
      def serialize
        {
          id: order.id,
          budget: order.budget.title,
          component: order.budget.component.name,
          checked_out_at: order.checked_out_at,
          projects: all_projects,
          created_at: order.created_at,
          updated_at: order.updated_at
        }
      end

      private

      attr_reader :order
      alias resource order

      def all_projects
        order.projects.map do |project|
          {
            id: project.id,
            title: project.title,
            description: project.description,
            budget_amount: project.budget_amount,
            scope: project.try(:scope).try(:name),
            reference: project.reference,
            created_at: project.created_at,
            updated_at: project.updated_at
          }
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-budgets-0.29.1 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.28.4 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.27.9 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.29.0 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.28.3 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.27.8 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.29.0.rc4 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.29.0.rc3 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.29.0.rc2 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.29.0.rc1 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.28.2 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.27.7 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.28.1 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.27.6 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.28.0 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.27.5 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.28.0.rc5 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.28.0.rc4 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.27.4 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb
decidim-budgets-0.27.3 app/serializers/decidim/budgets/download_your_data_budgets_order_serializer.rb