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