Class: Decidim::Commands::SoftDeleteResource
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Commands::SoftDeleteResource
- Defined in:
- decidim-core/lib/decidim/commands/soft_delete_resource.rb
Instance Method Summary collapse
-
#call ⇒ Object
Soft deletes the resource.
-
#initialize(resource, current_user) ⇒ SoftDeleteResource
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) ⇒ SoftDeleteResource
Initializes the command.
10 11 12 13 |
# File 'decidim-core/lib/decidim/commands/soft_delete_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
Soft deletes the resource.
Broadcasts :ok if successful, :invalid otherwise.
18 19 20 21 22 23 24 25 26 27 |
# File 'decidim-core/lib/decidim/commands/soft_delete_resource.rb', line 18 def call return broadcast(:invalid) if invalid? soft_delete_resource broadcast(:ok, resource) rescue Decidim::Commands::HookError, StandardError broadcast(:invalid) end |