Sha256: e40643b8a3e174811cc5aa0d6328af0f19a45a75f426d316c655b6c2c463518e

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true
module Decidim
  module Proposals
    # A command with all the business logic when a user creates a new proposal.
    class CreateProposalExport < Rectify::Command
      # Public: Initializes the command.
      #
      # form         - A form object with the params.
      # current_user - The current user.
      def initialize(participatory_process)
        @participatory_process = participatory_process
      end

      # Executes the command. Broadcasts these events:
      #
      # - :ok when everything is valid, together with the proposal.
      # - :invalid if the proposal wasn't valid and we couldn't proceed.
      #
      # Returns nothing.
      def call
        return broadcast(:invalid) if participatory_process.invalid?

        create_proposal_export
        broadcast(:ok, export)
      end

      private

      attr_reader :participatory_process

      def create_proposal_export
        ProposalsExporterJob.perform_later(participatory_process)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
decidim-proposals-0.1.0 app/commands/decidim/proposals/create_proposal_export.rb
decidim-0.1.0 decidim-proposals/app/commands/decidim/proposals/create_proposal_export.rb