Sha256: dc00c61a12f0071d957a43b854af41a450b797180320029c6e2740a4e3380496

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    module Admin
      # A command with all the business logic when destroying an conference
      # admin in the system.
      class DestroyConferenceAdmin < Decidim::Command
        # Public: Initializes the command.
        #
        # role - the ConferenceUserRole to destroy
        # current_user - the user performing this action
        def initialize(role, current_user)
          @role = role
          @current_user = current_user
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when everything is valid.
        # - :invalid if the form wasn't valid and we couldn't proceed.
        #
        # Returns nothing.
        def call
          destroy_role!
          broadcast(:ok)
        end

        private

        attr_reader :role, :current_user

        def destroy_role!
          extra_info = {
            resource: {
              title: role.user.name
            }
          }

          Decidim.traceability.perform_action!(
            "delete",
            role,
            current_user,
            extra_info
          ) do
            role.destroy!
            role
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-conferences-0.27.3 app/commands/decidim/conferences/admin/destroy_conference_admin.rb
decidim-conferences-0.27.2 app/commands/decidim/conferences/admin/destroy_conference_admin.rb
decidim-conferences-0.27.1 app/commands/decidim/conferences/admin/destroy_conference_admin.rb
decidim-conferences-0.27.0 app/commands/decidim/conferences/admin/destroy_conference_admin.rb
decidim-conferences-0.27.0.rc2 app/commands/decidim/conferences/admin/destroy_conference_admin.rb
decidim-conferences-0.27.0.rc1 app/commands/decidim/conferences/admin/destroy_conference_admin.rb