Class: Decidim::Admin::DestroyComponent
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::DestroyComponent
- Defined in:
- app/commands/decidim/admin/destroy_component.rb
Overview
This command deals with destroying a Component from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Public: Executes the command.
-
#initialize(component, current_user) ⇒ DestroyComponent
constructor
Public: Initializes the command.
Constructor Details
#initialize(component, current_user) ⇒ DestroyComponent
Public: Initializes the command.
component - The Component to be destroyed. current_user - the user performing the action
11 12 13 14 |
# File 'app/commands/decidim/admin/destroy_component.rb', line 11 def initialize(component, current_user) @component = component @current_user = current_user end |
Instance Method Details
#call ⇒ Object
Public: Executes the command.
Broadcasts :ok if it got destroyed, raises an exception otherwise.
19 20 21 22 23 24 25 26 |
# File 'app/commands/decidim/admin/destroy_component.rb', line 19 def call begin destroy_component rescue StandardError return broadcast(:invalid) end broadcast(:ok) end |