Sha256: e5ff3f972b68f4685e363e09ef8523338d42ee39ecf940fcbcb73fcc5cf9c7e5

Contents?: true

Size: 874 Bytes

Versions: 16

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A command that sets a participatory process as published.
    class PublishParticipatoryProcess < Rectify::Command
      # Public: Initializes the command.
      #
      # process - A ParticipatoryProcess that will be published
      def initialize(process)
        @process = process
      end

      # Executes the command. Broadcasts these events:
      #
      # - :ok when everything is valid.
      # - :invalid if the data wasn't valid and we couldn't proceed.
      #
      # Returns nothing.
      def call
        return broadcast(:invalid) if process.nil? || process.published?

        publish_process
        broadcast(:ok)
      end

      private

      attr_reader :process

      def publish_process
        process.update_attribute(:published_at, Time.current)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
decidim-admin-0.4.3 app/commands/decidim/admin/publish_participatory_process.rb
decidim-admin-0.4.2 app/commands/decidim/admin/publish_participatory_process.rb
decidim-admin-0.4.1 app/commands/decidim/admin/publish_participatory_process.rb
decidim-0.4.3 decidim-admin/app/commands/decidim/admin/publish_participatory_process.rb
decidim-0.4.2 decidim-admin/app/commands/decidim/admin/publish_participatory_process.rb
decidim-0.4.1 decidim-admin/app/commands/decidim/admin/publish_participatory_process.rb
decidim-admin-0.4.0 app/commands/decidim/admin/publish_participatory_process.rb
decidim-0.4.0 decidim-admin/app/commands/decidim/admin/publish_participatory_process.rb
decidim-admin-0.3.2 app/commands/decidim/admin/publish_participatory_process.rb
decidim-0.3.2 decidim-admin/app/commands/decidim/admin/publish_participatory_process.rb
decidim-admin-0.3.1 app/commands/decidim/admin/publish_participatory_process.rb
decidim-0.3.1 decidim-admin/app/commands/decidim/admin/publish_participatory_process.rb
decidim-admin-0.3.0 app/commands/decidim/admin/publish_participatory_process.rb
decidim-0.3.0 decidim-admin/app/commands/decidim/admin/publish_participatory_process.rb
decidim-admin-0.2.0 app/commands/decidim/admin/publish_participatory_process.rb
decidim-0.2.0 decidim-admin/app/commands/decidim/admin/publish_participatory_process.rb