Class: Decidim::Templates::Admin::DestroyTemplate

Inherits:
Command
  • Object
show all
Defined in:
decidim-templates/app/commands/decidim/templates/admin/destroy_template.rb

Overview

This command deals with destroying a template from the admin panel.

Direct Known Subclasses

DestroyQuestionnaireTemplate

Instance Method Summary collapse

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events

Constructor Details

#initialize(template, current_user) ⇒ DestroyTemplate

Public: Initializes the command.

template - The Template to be destroyed. user - The user that destroys the template.



12
13
14
15
# File 'decidim-templates/app/commands/decidim/templates/admin/destroy_template.rb', line 12

def initialize(template, current_user)
  @template = template
  @current_user = current_user
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject

Public: Executes the command.

Broadcasts :ok if it got destroyed



20
21
22
23
# File 'decidim-templates/app/commands/decidim/templates/admin/destroy_template.rb', line 20

def call
  destroy_template
  broadcast(:ok)
end