Class: Decidim::Commands::DestroyResource
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Commands::DestroyResource
- Defined in:
- lib/decidim/commands/destroy_resource.rb
Instance Method Summary collapse
-
#call ⇒ Object
Destroys the result.
-
#initialize(resource, current_user) ⇒ DestroyResource
constructor
Initializes the command.
Methods inherited from Decidim::Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(resource, current_user) ⇒ DestroyResource
Initializes the command.
10 11 12 13 |
# File 'lib/decidim/commands/destroy_resource.rb', line 10 def initialize(resource, current_user) @resource = resource @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
#call ⇒ Object
Destroys the result.
Broadcasts :ok if successful, :invalid otherwise.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/decidim/commands/destroy_resource.rb', line 18 def call return broadcast(:invalid) if invalid? run_before_hooks destroy_resource run_after_hooks broadcast(:ok, resource) rescue Decidim::Commands::HookError, StandardError broadcast(:invalid) end |