app/commands/decidim/admin/destroy_area.rb in decidim-admin-0.28.4 vs app/commands/decidim/admin/destroy_area.rb in decidim-admin-0.29.0.rc1

- old
+ new

@@ -1,44 +1,21 @@ # frozen_string_literal: true module Decidim module Admin # A command with all the business logic to destroy an area. - class DestroyArea < Decidim::Command - # Public: Initializes the command. - # - # area - The area to destroy - # current_user - the user performing the action - def initialize(area, current_user) - @area = area - @current_user = current_user - end - + class DestroyArea < Decidim::Commands::DestroyResource # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the form was not valid and we could not proceed. # # Returns nothing. def call - destroy_area + destroy_resource broadcast(:ok) rescue ActiveRecord::RecordNotDestroyed broadcast(:has_spaces) - end - - private - - attr_reader :current_user - - def destroy_area - Decidim.traceability.perform_action!( - "delete", - @area, - current_user - ) do - @area.destroy! - end end end end end