Sha256: 7af6a7305b4954005901409476bd6701305c1c5eeef6c8cd5e490767d7936f33

Contents?: true

Size: 936 Bytes

Versions: 2

Compression:

Stored size: 936 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # This command gets called when a feature is unpublished from the admin panel.
    class UnpublishFeature < Rectify::Command
      # Public: Initializes the command.
      #
      # feature - The feature to unpublish.
      # current_user - the user performing the action
      def initialize(feature, current_user)
        @feature = feature
        @current_user = current_user
      end

      # Public: Unpublishes the Feature.
      #
      # Broadcasts :ok if unpublished, :invalid otherwise.
      def call
        unpublish_feature

        broadcast(:ok)
      end

      private

      attr_reader :feature, :current_user

      def unpublish_feature
        Decidim.traceability.perform_action!(
          :unpublish,
          feature,
          current_user
        ) do
          feature.unpublish!
          feature
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
decidim-admin-0.10.1 app/commands/decidim/admin/unpublish_feature.rb
decidim-admin-0.10.0 app/commands/decidim/admin/unpublish_feature.rb